return vowFs.exists(TEST_SNAPSHOT_PATH).then(function (exists) { exists.should.be.ok; return vow.all([ vowFs.listDir(path.join(TEST_DB_PATH, 'leveldb')), vowFs.listDir(path.join(TEST_SNAPSHOT_PATH, 'leveldb')) ]).spread(function (files1, files2) { files1.should.be.instanceOf(Array); files2.should.be.instanceOf(Array); files1.length.should.be.above(0); files2.length.should.be.above(0); files1.length.should.equal(files2.length); done(); }); });
Checker.prototype._processDirectory = function(path, fileHandler) { return vowFs.listDir(path).then(function(filenames) { return Vow.all(filenames.map(function(filename) { var fullname = path + '/' + filename; if (this._configuration.isFileExcluded(fullname)) { return []; } return vowFs.stat(fullname).then(function(stat) { if (stat.isDirectory()) { return this._processDirectory(fullname, fileHandler); } if (!this._hasCorrectExtension(fullname)) { if (!this._configuration.shouldExtractFile(fullname)) { return []; } return this.extractFile(fullname); } return fileHandler(fullname); }, this); }, this)).then(function(results) { return [].concat.apply([], results); }); }, this); };
checkDirectory: function(path) { var _this = this; return vowFs.listDir(path).then(function(filenames) { return Vow.all(filenames.map(function(filename) { var fullname = path + '/' + filename; // check for exclude path if (_this._shouldProcess(fullname)) { return vowFs.stat(fullname).then(function(stat) { if (stat.isDirectory()) { return _this.checkDirectory(fullname); } else if (fullname.match(/\.js$/)) { return Vow.when(_this.checkFile(fullname)).then(function(errors) { if (errors) { return errors; } else { return []; } }); } else { return []; } }); } else { return []; } })).then(function(results) { return [].concat.apply([], results); }); }); },
Checker.prototype.checkDirectory = function(path) { var _this = this; return vowFs.listDir(path).then(function(filenames) { return Vow.all(filenames.map(function(filename) { var fullname = path + '/' + filename; // check for exclude path if (_this._isExcluded(fullname)) { return []; } return vowFs.stat(fullname).then(function(stat) { if (stat.isDirectory()) { return _this.checkDirectory(fullname); } if (!_this._hasCorrectExtension(fullname)) { return []; } return Vow.when(_this.checkFile(fullname)).then(function(errors) { if (errors) { return errors; } return []; }); }); })).then(function(results) { return [].concat.apply([], results); }); }); };
_loadFromDir: function(dirname, recursive) { var _this = this; return vowFs.listDir(dirname).then(function(filenames) { return Vow.all(filenames.map(function(filename) { var fullname = dirname + '/' + filename; return vowFs.stat(fullname).then(function(stat) { if (stat.isFile()) { return [{ name: filename, fullname: fullname, suffix: getSuffix(filename), mtime: +stat.mtime }]; } else if (stat.isDirectory()) { if (recursive) { return _this._loadFromDir(fullname, recursive); } } return []; }); })); }).then(function(fileLists) { return [].concat.apply([], fileLists); }); },
Lesshint.prototype.checkDirectory = function (checkPath) { return fs.listDir(checkPath).then(function (files) { files = files.map(function (file) { var fullPath = path.join(checkPath, file); return fs.stat(fullPath).then(function (stats) { if (stats.isDirectory()) { return this.checkDirectory(fullPath); } // Check if the file should be excluded if (this.isExcluded(fullPath)) { return []; } // Check if the file has the correct extension if (!this.hasAllowedExtension(file)) { return []; } return this.checkFile(fullPath); }, this); }, this); return Vow.all(files).then(function (results) { return [].concat.apply([], results); }); }, this); };
.then(function () { return vowFs.listDir(constants.DIRECTORY.CONTENT).then(function (dirs) { return vow.all(dirs.map(function (dir) { var p = path.join(constants.DIRECTORY.CONTENT, dir); logger.debug(util.format('remove directory %s', p), module); return utility.removeDir(p); })); }); })
targets.map(function(relPath) { var dir = path.join(cwd, relPath); VowFs.listDir(dir) .then(function (files) { files.map(function(file) { var key = path.join(dir, file); dropRequireCache(require, key); }); }); })
return vowFs.stat(filename).then(function (stat) { if (stat.isDirectory()) { return vowFs.listDir(filename).then(function (items) { return vow.all(items.map(function (item) { return _this._collectFiles(path.join(filename, item), excludes, root); })).then(function (results) { return Array.prototype.concat.apply([], results); }); }); } else { return [filename]; } });
var scanDir = function (rootPath) { return vfs.listDir(rootPath) .then(function (files) { var all = []; for (var i = 0; i < files.length; i++) { all.push(processDirItem(rootPath + '/' + files[i])); } return vow.all(all); }) .catch(function(){ throw "Fail to list directory: " + rootPath; }); };
Posts.loadPosts = function (directoryPath) { return vowFs.listDir(directoryPath).then(function (filenames) { return vow.all( filenames .map(function (filename) { return directoryPath + '/' + filename; }) .map(function (filePath) { return Post.parseFile(filePath); }) ) .then(function (postsArray) { return new Posts(postsArray); }); }); };
this.processDirectory = function processDirectory(path) { return vfs.listDir(path).then(function(filenames) { return vow.all(filenames.map(function(filename) { var fullname = path + '/' + filename; return vfs.stat(fullname).then(function(stat) { if (stat.isDirectory()) { return shouldProcess(fullname) && _this.processDirectory(fullname); } else { return _this.processFile(fullname); } }); })).then(function(results) { return [].concat.apply([], results); }); }); };
/** * Processes directory recursively. * * @param {String} path * @returns {Promise} */ processDirectory(path) { let that = this; return vfs.listDir(path).then(function(filenames) { return vow.all(filenames.map(function(filename) { let fullname = path + '/' + filename; return vfs.stat(fullname).then(function(stat) { if (stat.isDirectory() && that._shouldProcess(fullname)) { return that.processDirectory(fullname); } else { return that.processFile(fullname); } }); })).then(function(results) { return [].concat.apply([], results); }); }); }
/** * Reads markdown files from filesystem * @param {Target} target model * @param {Object} result model * @param {String} key with name of markdown doc * @returns {*} */ function loadMDFromFile(target, result, key) { return vowFs .listDir(path.join(target.getContentPath(), target.getMdTargets()[key].folder)) .then(function (files) { var languages = config.get('languages') || ['en'], pattern = target.getMdTargets()[key].pattern; if (!_.isObject(pattern)) { pattern = languages.reduce(function (prev, lang) { prev[lang] = pattern; return prev; }, {}); } result[key] = { title: target.getTitles()[key], content: null }; return vow.allResolved(Object.keys(pattern).map(function (lang) { var file = files .filter(function (file) { return file.indexOf(pattern[lang]) !== -1; }) .sort(function (a, b) { var toVersion = function (str) { return str.replace(pattern[lang], '').replace('-', '').replace('.', ''); }; return toVersion(a) - toVersion(b); }) .pop(); return vowFs .read(path.join(path.join(target.getContentPath(), target.getMdTargets()[key].folder), file), 'utf-8') .then(function (content) { try { result[key].content = result[key].content || {}; result[key].content[lang] = utility.mdToHtml(content); }catch (e) {} }); })); }); }
/** * Scan block directories for level * @param {Target} target model * @param {Object} level * @returns {*} */ function readBlocksForLevel(target, level) { var blockIgnores = ['.dist', '.bem', 'index', 'catalogue', 'index', 'jscatalogue']; return vowFs.listDir(path.resolve(target.getOutputPath(), level.name)) .then(function (blocks) { return vow.allResolved( blocks .filter(function (block) { return blockIgnores.indexOf(block) === -1; }) .map(function (block) { block = { name: block }; level.blocks = level.blocks || []; level.blocks.push(block); return readDataForBlock(this, level, block); }, this) ); }, target); }
/** * Scan level directories for library * @param {Target} target model * @param {Object} result model * @returns {*} */ function readLevelsForLibrary(target, result) { logger.debug(util.format('read level directories for library %s', target.getName()), module); return vowFs.listDir(path.resolve(target.getOutputPath())) .then(function (levels) { var levelNames = constants.LEVELS.map(function (item) { return item + target.getDocPatterns().replace('*', ''); }); levels = levels.filter(function (item) { return levelNames.indexOf(item) !== -1; }); return vow.allResolved(levels.map(function (level) { level = { name: level }; result.levels = result.levels || []; result.levels.push(level); return readBlocksForLevel(target, level); })); }); }
this.processDirectory = function processDirectory(path) { _$jscmd("lib/utils.js", "line", 343); return vfs.listDir(path).then(function(filenames) { _$jscmd("lib/utils.js", "line", 344); return vow.all(filenames.map(function(filename) { _$jscmd("lib/utils.js", "line", 345); var fullname = _$jscmd("lib/utils.js", "cond", "345_31_10", _$jscmd("lib/utils.js", "cond", "345_31_4", path) + "/") + _$jscmd("lib/utils.js", "cond", "345_44_8", filename); _$jscmd("lib/utils.js", "line", 346); return vfs.stat(fullname).then(function(stat) { if (stat.isDirectory()) { _$jscmd("lib/utils.js", "line", 348); return _$jscmd("lib/utils.js", "cond", "348_31_23", shouldProcess(fullname)) && _$jscmd("lib/utils.js", "cond", "348_58_32", _this.processDirectory(fullname)); } else { _$jscmd("lib/utils.js", "line", 350); return _this.processFile(fullname); } }); })).then(function(results) { _$jscmd("lib/utils.js", "line", 354); return [].concat.apply([], results); }); }); };
var spawn = require('child_process').spawn; var chalk = require('chalk'); var vow = require('vow'); var vowFs = require('vow-fs'); var SOURCES = ['lib', 'test/specs']; var MOCHA = 'node_modules/.bin/mocha'; /** * Applying every available preset to JSCS sources and tests, then executing tests. * So we can make sure nothing breaks during these reformatting actions. */ vowFs.listDir('./presets') .then(function(presetFilenames) { var presets = presetFilenames.map(function(presetFilename) { return presetFilename.replace('.json', ''); }); console.log('\n' + chalk.green('> ') + 'Autofix ingeration tests'); return promiseQueue(presets, function(presetName) { console.log('\nPreset "' + chalk.green(presetName) + '"'); logStep('Autofix execution'); return applyPreset(presetName).then( function() { logStep('Unit tests'); console.log(''); return runTests().then( function() { console.log(''); logStep('Unit test on "' + chalk.green(presetName) + '" preset are finished'); }, logErrorHandler('Unit tests failure'),
path = require('path'), vow = require('vow'), vowFs = require('vow-fs'), utility = require('./../src/util'), config = require('./../src/config'), logger = require('./../src/logger'), constants = require('./../src/constants'), storage = require('../src/storage'), FREEZE = 'freeze', options = config.get('storage'), basePath = path.join(process.cwd(), FREEZE); vowFs.listDir(basePath) .then(function (files) { var openFilesLimit = config.get('maxOpenFiles') || constants.MAXIMUM_OPEN_FILES, portions = utility.separateArrayOnChunks(files, openFilesLimit); return portions.reduce(function (prev, item, index) { prev = prev.then(function () { logger.info(util.format('send files in range %s - %s', index * openFilesLimit, (index + 1) * openFilesLimit), module); return vow.all(item.map(function (_item) { var fPath = path.join(basePath, _item), key = util.format('%s/%s', FREEZE, _item); logger.debug(util.format('send file %s', _item), module); return vowFs.read(fPath, 'utf-8').then(function (content) {
var path = require('path'); var vow = require('vow'); var vowFs = require('vow-fs'); var StaticPage = require('./static-page'); var LANG = 'ru'; vowFs .listDir('build') .then(function (list) { var pagesPromises = list.map(function (pageName) { return StaticPage.make(pageName, LANG); }); return vow.all([ pagesPromises ]); }) .done();
function dirlist(level) { return fs.listDir(level); }