How to use the graceful-fs.readdirSync function in graceful-fs

To help you get started, we’ve selected a few graceful-fs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hex7c0 / mongodb-restore / index.js View on Github external
function rmDir(pathname, next) {

  fs.readdirSync(pathname).forEach(function(first) { // database

    var database = pathname + first;
    if (fs.statSync(database).isDirectory() === false) {
      return;
    }

    var metadata = '';
    var collections = fs.readdirSync(database);
    var metadataPath = path.join(database, '.metadata');
    if (fs.existsSync(metadataPath) === true) {
      metadata = metadataPath + path.sep;
      delete collections[collections.indexOf('.metadata')]; // undefined is not a dir
    }

    collections.forEach(function(second) { // collection
github gavoja / aemsync / aemsync.js View on Github external
// Check return condition.
	if (returnCallback && returnCallback(localPath, stats)) {
		return results;
	}

	// Add current item.
	results.push(localPath);

	// No need for recursion if not a directory.
	if (!stats.isDirectory()) {
		return results;
	}

	// Iterate over list of children.
	var list = fs.readdirSync(localPath);
	list.forEach(function (file) {
		file = localPath + "/" + file;
		results = results.concat(walkSync(file, returnCallback));
	});

	return results;
}
github hw2-archive / upt / test / core / resolveCache.js View on Github external
.spread(function () {
                var dirs = fs.readdirSync(sourceDir);

                expect(arguments.length).to.equal(0);
                expect(dirs).to.contain('0.0.1');
                expect(dirs).to.contain('0.2.0');
                next();
            })
            .done();
github hw2-archive / upt / test / core / resolvers / svnResolver.js View on Github external
.then(function (dir) {
                expect(dir).to.be.a('string');

                var files = fs.readdirSync(dir);

                expect(files).to.not.contain('foo');
                expect(files).to.not.contain('bar');
                expect(files).to.not.contain('baz');
                next();
            })
            .done();
github sx1989827 / DOClever / node_modules / phantomjs-prebuilt / node_modules / fs-extra / lib / copy-sync / copy-sync.js View on Github external
var destFolderExists = fs.existsSync(destFolder)
  var performCopy = false

  if (stats.isFile()) {
    if (options.filter instanceof RegExp) {
      console.warn('Warning: fs-extra: Passing a RegExp filter is deprecated, use a function')
      performCopy = options.filter.test(src)
    } else if (typeof options.filter === 'function') performCopy = options.filter(src)

    if (performCopy) {
      if (!destFolderExists) mkdir.mkdirsSync(destFolder)
      copyFileSync(src, dest, {clobber: options.clobber, preserveTimestamps: options.preserveTimestamps})
    }
  } else if (stats.isDirectory()) {
    if (!fs.existsSync(dest)) mkdir.mkdirsSync(dest)
    var contents = fs.readdirSync(src)
    contents.forEach(function (content) {
      var opts = options
      opts.recursive = true
      copySync(path.join(src, content), path.join(dest, content), opts)
    })
  } else if (options.recursive && stats.isSymbolicLink()) {
    var srcPath = fs.readlinkSync(src)
    fs.symlinkSync(srcPath, dest)
  }
}
github gameclosure / devkit / src / ProjectManager.js View on Github external
this.loadConfig = function (reload) {
		if (this._reloading) { return; }
		this._reloading = true;

		var localProjectsPath = common.paths.root('./projects');
		var localProjects = [];
		fs.readdirSync(localProjectsPath).map(function (filename) {
			return common.paths.projects(filename);
		}).forEach(function(item) {
			if (path.basename(item).charAt(0) != '.') {
				localProjects.push(item);
			}
		});
		var configProjects = common.config.get('projects') || [];
		this._projectDirs = configProjects.concat(localProjects);

		var projects = {};
		var added = [];
		var removed = merge({}, this._projects);
		var f = ff(this, function() {
			this._projectDirs.forEach(function (dir) {
				var next = f.wait();
github tidys / CocosCreatorPlugins / packages / excel-killer / node_modules / fs-extra / lib / copy-sync / copy-sync.js View on Github external
function copyDir (src, dest, opts) {
  fs.readdirSync(src).forEach(item => {
    startCopy(path.join(src, item), path.join(dest, item), opts)
  })
}
github DevAlien / dripr-ui / webpack / config.js View on Github external
entry: {
    main: [
      './src/server'
    ]
  },
  target: 'node',
  output: {
    library: true,
    libraryTarget: 'commonjs2',
    pathinfo: true,
    path: path.join(__dirname, '../server/build'),
    filename: '[name].js',
    chunkFilename: '[name].js',
    publicPath: '/build/'
  },
  externals: fs.readdirSync(path.join(__dirname, '../node_modules'))
    .map(key => new RegExp(`^${key}`))
});
github devopsgroup-io / veeva / lib / utils.js View on Github external
getFiles: function (srcpath) {
        return fs.readdirSync(srcpath).filter(function (file) {
          return fs.statSync(path.join(srcpath, file)).isFile();
        });
    },
    rm: function (filename) {
github ionic-team / stencil / src / sys / node_next / node-sys.ts View on Github external
readdirSync(p) {
      try {
        return fs.readdirSync(p).map(f => {
          return normalizePath(path.join(p, f));
        });
      } catch (e) {}
      return [];
    },
    readFile(p) {