コード例 #1
0
ファイル: utils.js プロジェクト: mochasteak/forecite-mockups
 return vfs.read(path, "utf8").then(function(data) {
     _$jscmd("lib/utils.js", "line", 368);
     var syntax = path.split(".").pop();
     _$jscmd("lib/utils.js", "line", 369);
     var processedData = _this.processString(data, {
         syntax: syntax,
         filename: path
     });
     _$jscmd("lib/utils.js", "line", 370);
     var isChanged = _$jscmd("lib/utils.js", "cond", "370_28_4", data) !== _$jscmd("lib/utils.js", "cond", "370_37_13", processedData);
     if (lint) {
         _$jscmd("lib/utils.js", "line", 373);
         console.log(isChanged ? _$jscmd("lib/utils.js", "cond", "373_40_3", "!") : _$jscmd("lib/utils.js", "cond", "373_46_3", " "), path);
         _$jscmd("lib/utils.js", "line", 374);
         return isChanged ? _$jscmd("lib/utils.js", "cond", "374_35_1", 1) : _$jscmd("lib/utils.js", "cond", "374_39_1", 0);
     } else if (!isChanged) {
         if (verbose) console.log(" ", path);
         _$jscmd("lib/utils.js", "line", 377);
         return 0;
     } else {
         _$jscmd("lib/utils.js", "line", 379);
         return vfs.write(path, processedData, "utf8").then(function() {
             if (verbose) console.log("✓", path);
             _$jscmd("lib/utils.js", "line", 381);
             return 1;
         });
     }
 });
コード例 #2
0
ファイル: index.js プロジェクト: belyanskii/bem-ide
        return fs.exists(path).then(function(exists) {
            if(exists) {
                return fs.write(path, content).then(function(err) {
                    if(err) throw err;

                    return {
                        path: item.path,
                        status: 'Saved!'
                    };
                });
            } else {
                return fs.makeDir(PATH.dirname(path)).then(function(err) {
                    if(err) return cb(err);

                    return fs.write(path, content).then(function(err) {
                        if(err) throw err;

                        return {
                            path: item.path,
                            status: 'Created!'
                        };
                    });
                });
            }
        });
コード例 #3
0
            .then(function (structuredResult) {

                var paths = structuredResult.join(',').split(',').filter(function (x) {
                    return !!x
                });
                var dictionary = {};

                var files = [];
                for (var i = 0; i < paths.length; i++) {
                    console.log('Found file: ' + paths[i]);
                    var namespace = paths[i].replace(argv.i, '');
                    var item = {
                        filePath: paths[i],
                        content: JSON.parse(fs.readFileSync(paths[i]).toString()),
                        namespace: namespace,
                        propertyPath: namespace.replace(argv.propertyPathRegExp, '').replace(/^[\\\/]/, '').split(/[\\\/]/)
                    };

                    files.push(item);

                    for (var j in item.content) {
                        if (item.content.hasOwnProperty(j)) {
                            if (!dictionary.hasOwnProperty(j)) {
                                dictionary[j] = {};
                            }
                            dictionary[j] = injectIntoJson(dictionary[j], item.propertyPath, item.content[j]);
                        }
                    }
                }

                return vfs.write(argv.o, JSON.stringify(helpers.sort(dictionary), null, 4));
            })
コード例 #4
0
ファイル: util.js プロジェクト: 4exova/borschik
        .then(function(res){

            // save res to file
            if (typeof output === 'string') {
                return VOWFS.write(output, res);
            }

            // write res to writable stream of opened file
            var defer = VOW.promise();

            // output res to stdout
            if (output === process.stdout) {
                output.write(res);
                return defer.fulfill();
            }

            output.on('error', function(err) {
                defer.reject(err);
            });

            output.once('close', function() {
                defer.fulfill();
            });

            output.once('end', function() {
                defer.fulfill();
            });

            output.write(res);
            output.end();

            return defer;

        });
コード例 #5
0
ファイル: collect-sets.js プロジェクト: jk708/bem-data-source
/**
 * Save result model into json file
 * @param {Target} target model
 * @param {Object} result model
 * @returns {*}
 */
function writeResultToFile(target, result) {
    logger.debug(util.format('write result of target %s to file %s', target.getName(),
        path.resolve(target.getOutputPath(), constants.FILE.DATA)), module);

    return vowFs.write(path.resolve(target.getOutputPath(), constants.FILE.DATA),
        JSON.stringify(result), { charset: 'utf8' });
}
コード例 #6
0
ファイル: file-copy.js プロジェクト: bratva/enb
 return vowFs.read(sourcePath, 'utf8').then(function(data) {
     return vowFs.write(targetPath, data, 'utf8').then(function() {
         cache.cacheFileInfo('source-file', sourcePath);
         cache.cacheFileInfo('target-file', targetPath);
         _this.node.resolveTarget(target);
     });
 });
コード例 #7
0
ファイル: release.js プロジェクト: dmikis/bla
 .then(function (pkgJson) {
     var data = JSON.parse(pkgJson);
     data.version = newVersion;
     return vowFs.write(
         './package.json',
         JSON.stringify(data, null, pkgJsonIndent) + '\n'
     );
 });
コード例 #8
0
ファイル: node.js プロジェクト: bratva/enb
 return vowFs.exists(filename).then(function(exists) {
     if (exists) {
         return createTmpFilename();
     } else {
         return vowFs.write(filename, '').then(function() {
             return filename;
         });
     }
 });
コード例 #9
0
ファイル: deps-old.js プロジェクト: ignovak/enb
 }).then(function(resolvedDeps) {
     resolvedDeps = resolvedDeps.getDeps();
     return vowFs.write(depsTargetPath, 'exports.deps = ' + JSON.stringify(resolvedDeps, null, 4) + ';', 'utf8').then(function() {
         cache.cacheFileInfo('deps-file', depsTargetPath);
         cache.cacheFileInfo('bemdecl-file', bemdeclSourcePath);
         cache.cacheFileList('deps-file-list', depFiles);
         _this.node.resolveTarget(depsTarget, resolvedDeps);
     });
 }));
コード例 #10
0
ファイル: static-page.js プロジェクト: bevis-ui/bevis-stub
    _makeStaticPage: function(pageName, html) {
        var fileName = path.basename(pageName);
        var filePath = pageName + '/' + fileName + '.html';

        return vowFs
            .write(filePath, html)
            .then(function () {
                return filePath;
            });
    }
コード例 #11
0
ファイル: core.js プロジェクト: banjo78910/bogoSite
      }).then(function (processedData) {
        if (data === processedData) {
          if (that.verbose) console.log(' ', path);
          return 0;
        }

        return vfs.write(path, processedData, 'utf8').then(function () {
          if (that.verbose) console.log('✓', path);
          return 1;
        });
      });
コード例 #12
0
ファイル: deps.js プロジェクト: escaton/enb
        return this.node.requireSources([this._levelsTarget, bemdeclSource]).spread(function(levels) {
            var depFiles = levels.getFilesBySuffix('deps.js');
            if (cache.needRebuildFile('deps-file', depsTargetPath)
                    || cache.needRebuildFile('bemdecl-file', bemdeclSourcePath)
                    || cache.needRebuildFileList('deps-file-list', depFiles)) {
                delete require.cache[bemdeclSourcePath];
                var bemdecl = require(bemdeclSourcePath),
                    dep = new DepsResolver(levels);

                bemdecl.blocks && bemdecl.blocks.forEach(function(block) {
                    dep.addBlock(block.name);
                    if (block.mods) {
                        block.mods.forEach(function(mod) {
                            if (mod.vals) {
                                mod.vals.forEach(function(val) {
                                    dep.addBlock(block.name, mod.name, val.name);
                                });
                            }
                        });
                    }
                    if (block.elems) {
                        block.elems.forEach(function(elem){
                            dep.addElem(block.name, elem.name);
                            if (elem.mods) {
                                elem.mods.forEach(function(mod) {
                                    if (mod.vals) {
                                        mod.vals.forEach(function(val) {
                                            dep.addElem(block.name, elem.name, mod.name, val.name);
                                        });
                                    }
                                });
                            }
                        });
                    }
                });

                bemdecl.deps && dep.normalizeDeps(bemdecl.deps).forEach(function(decl) {
                    dep.addDecl(decl);
                });

                var resolvedDeps = dep.resolve();
                return vowFs.write(depsTargetPath, 'exports.deps = ' + JSON.stringify(resolvedDeps, null, 4) + ';', 'utf8').then(function() {
                    cache.cacheFileInfo('deps-file', depsTargetPath);
                    cache.cacheFileInfo('bemdecl-file', bemdeclSourcePath);
                    cache.cacheFileList('deps-file-list', depFiles);
                    _this.node.resolveTarget(depsTarget, resolvedDeps);
                });
            } else {
                _this.node.isValidTarget(depsTarget);
                delete require.cache[depsTargetPath];
                _this.node.resolveTarget(depsTarget, require(depsTargetPath).deps);
                return null;
            }
        });
コード例 #13
0
 return additionalInfoPromise.then(function () {
     var report = reporter(coverageInfo);
     if (options.reportOutputFilename) {
         return vowFs.write(options.reportOutputFilename, report, 'utf8').then(function () {
             if (!options.quiet) {
                 console.log('Report saved: ' + options.reportOutputFilename);
             }
         });
     } else {
         process.stdout.write(report);
     }
 });
コード例 #14
0
ファイル: utils.js プロジェクト: mochasteak/forecite-mockups
        return vfs.read(path, 'utf8').then(function(data) {
            var syntax = path.split('.').pop();
            var processedData = _this.processString(data, { syntax: syntax, filename: path });
            var isChanged = data !== processedData;

            if (lint) {
                console.log(isChanged ? '!' : ' ', path);
                return isChanged ? 1 : 0;
            } else if (!isChanged) {
                if (verbose) console.log(' ', path);
                return 0;
            } else {
                return vfs.write(path, processedData, 'utf8').then(function() {
                    if (verbose) console.log('✓', path);
                    return 1;
                });
            }
        });
コード例 #15
0
ファイル: core.js プロジェクト: warmrobot/core
        return vfs.read(path, 'utf8').then(function(data) {
            var syntax = path.split('.').pop();
            var processedData = _this.processString(data, { syntax: syntax, filename: path });
            var isChanged = data !== processedData;

            var tick = isChanged ? (lint ? '!' : '✓') : ' ';
            var output = function() {
                if (verbose) console.log(tick, path);
                return {
                    path: path,
                    isChanged: isChanged ? 1 : 0
                };
            };

            if (!isChanged || lint) {
                return output();
            } else {
                return vfs.write(path, processedData, 'utf8').then(output);
            }
        });
コード例 #16
0
ファイル: csscomb.js プロジェクト: ArllanAndrade/csscomb.js
            return vfs.read(path, 'utf8').then(function(data) {
                var syntax = path.split('.').pop();
                var processedData = _this.processString(data, syntax, path);
                var changed = data !== processedData;
                var lint = _this._lint;

                var tick = changed ? (lint ? '!' : '✓') : ' ';
                var message = _this._verbose ? console.log.bind(null, tick, path) : doNothing;

                _this.processed++;
                changed && _this.tbchanged++;

                if (!changed || lint) {
                    message();
                } else {
                    return vfs.write(path, processedData, 'utf8').then(function() {
                        _this.changed++;
                        message();
                    });
                }
            });
コード例 #17
0
ファイル: core.js プロジェクト: liamtoo/csscombx
 }).then(function(processedData) {
   // Suppose there is no style file content shorter than 2 characters.
   if (!processedData || processedData.length < 3) {
     var status = !processedData ? 'empty:' : 'invalid:';
     if (that.verbose) console.log(status, path);
     resolve(0);
   }
   else if (data === processedData) {
     if (that.verbose) console.log('good:', path);
     resolve(0);
   }
   else if (that.lint) {
     if (that.verbose) console.log('bad:', path);
     resolve(0);
   } else {
     vfs.write(path, processedData, 'utf8').then(function() {
       if (that.verbose) console.log('now is good:', path);
       resolve(1);
     });
   }
 });
コード例 #18
0
ファイル: replace-doc.js プロジェクト: jk708/bem-data-source
 }).then(function (content) {
     var repoDir = path.join(constants.DIRECTORY.OUTPUT, repo),
         versionDir = path.join(repoDir, version),
         dataPath = path.join(versionDir, 'data.json');
     return vowFs.write(dataPath, JSON.stringify(content, null, 4), { charset: 'utf8' });
 }).then(function () {
コード例 #19
0
 return vowFs.read(filename, 'utf8').then(function (content) {
     return vowFs.write(filename, instrumenter.instrument(content, filename));
 }).then(function () {
コード例 #20
0
ファイル: cli.js プロジェクト: eGavr/toc-md
 .then(function (res) {
     return vfs.write(target, res)
         .then(function () {
             opts.clean ? log.successCleanMsg() : log.successInsertMsg();
         });
 });
コード例 #21
0
 return vowFs.read(path, 'utf8').then(function(data) {
     var result = this.fixString(data, path);
     return vowFs.write(path, result.output).then(function() {
         return result.errors;
     });
 }, this);
コード例 #22
0
ファイル: make.js プロジェクト: enb/enb
 .then(() => vfs.write(buildInfoFilename, JSON.stringify(buildInfo, null, 4)))
コード例 #23
0
ファイル: file-assemble-tech.js プロジェクト: escaton/enb
 .then(function(content) {
     return vowFs.write(_this.node.resolvePath(_this.getTargetName(suffix)), content, 'utf8');
 });
コード例 #24
0
ファイル: release.js プロジェクト: dmikis/bla
 .then(function (changelogContent) {
     return vowFs.write(
         changelogFile,
         newChangelogEntry + changelogContent
     );
 })