Ejemplo n.º 1
0
 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;
         });
     }
 });
Ejemplo n.º 2
0
        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!'
                        };
                    });
                });
            }
        });
Ejemplo n.º 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));
            })
Ejemplo n.º 4
0
        .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;

        });
Ejemplo n.º 5
0
/**
 * 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' });
}
Ejemplo n.º 6
0
 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);
     });
 });
Ejemplo n.º 7
0
 .then(function (pkgJson) {
     var data = JSON.parse(pkgJson);
     data.version = newVersion;
     return vowFs.write(
         './package.json',
         JSON.stringify(data, null, pkgJsonIndent) + '\n'
     );
 });
Ejemplo n.º 8
0
Archivo: node.js Proyecto: bratva/enb
 return vowFs.exists(filename).then(function(exists) {
     if (exists) {
         return createTmpFilename();
     } else {
         return vowFs.write(filename, '').then(function() {
             return filename;
         });
     }
 });
Ejemplo n.º 9
0
 }).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);
     });
 }));
Ejemplo n.º 10
0
    _makeStaticPage: function(pageName, html) {
        var fileName = path.basename(pageName);
        var filePath = pageName + '/' + fileName + '.html';

        return vowFs
            .write(filePath, html)
            .then(function () {
                return filePath;
            });
    }
Ejemplo n.º 11
0
      }).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;
        });
      });
Ejemplo n.º 12
0
Archivo: deps.js Proyecto: 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;
            }
        });
Ejemplo n.º 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);
     }
 });
Ejemplo n.º 14
0
        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;
                });
            }
        });
Ejemplo n.º 15
0
        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);
            }
        });
Ejemplo n.º 16
0
            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();
                    });
                }
            });
Ejemplo n.º 17
0
 }).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);
     });
   }
 });
Ejemplo n.º 18
0
 }).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 () {
Ejemplo n.º 19
0
 return vowFs.read(filename, 'utf8').then(function (content) {
     return vowFs.write(filename, instrumenter.instrument(content, filename));
 }).then(function () {
Ejemplo n.º 20
0
Archivo: cli.js Proyecto: eGavr/toc-md
 .then(function (res) {
     return vfs.write(target, res)
         .then(function () {
             opts.clean ? log.successCleanMsg() : log.successInsertMsg();
         });
 });
Ejemplo n.º 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);
Ejemplo n.º 22
0
Archivo: make.js Proyecto: enb/enb
 .then(() => vfs.write(buildInfoFilename, JSON.stringify(buildInfo, null, 4)))
Ejemplo n.º 23
0
 .then(function(content) {
     return vowFs.write(_this.node.resolvePath(_this.getTargetName(suffix)), content, 'utf8');
 });
Ejemplo n.º 24
0
 .then(function (changelogContent) {
     return vowFs.write(
         changelogFile,
         newChangelogEntry + changelogContent
     );
 })