How to use the fs-promise.readdir function in fs-promise

To help you get started, we’ve selected a few fs-promise 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 feramhq / typokit / index.js View on Github external
function getTypoMapsPromise () {
  return fsp
    .readdir(typoMapsPath)
    .then(fileNames => fileNames
      .filter(name => /\.yaml$/.test(name))
      .map(name => path.join(typoMapsPath, name))
    )
    .then(filePaths => Promise.all(
      filePaths.map(filePath => fsp.readFile(filePath))
    ))
    .then(fileContents => fileContents.map(yaml.safeLoad))
}
github ramoona / banks-db / lint.js View on Github external
jsonfile.readFile(path.join(__dirname, 'schema.json')).then((schema) => {
  fs.readdir(path.join(__dirname, 'banks')).then(files => lint(files, schema)).catch((err) => {
    logError(err);
    process.exit(1);
  });
}).catch(logError);
github elrumordelaluz / svgson / bin / svgson.js View on Github external
const readFolder = () => {
  if (!fs.statSync(SRC_DIR).isDirectory()) {
    sourceFile = path.basename(SRC_DIR);
    sourceDir = path.dirname(SRC_DIR);
    return Promise.resolve([SRC_DIR])
  }

  return fs.readdir(SRC_DIR);
};
github pencilblue / pencilblue / lib / utils / fileUtils.js View on Github external
static getDirectories (dirPath) {

        var dirs = [];
        return FsPromise.readdir(dirPath).then(function(files) {
            var promises = files.map(function (file) {
                var fullPath = path.join(dirPath, file);
                return FsPromise.stat(fullPath).then(function (stat) {
                    if (stat.isDirectory()) {
                        dirs.push(fullPath);
                    }
                });
            });
            return Q.all(promises).thenResolve(dirs);
        });
    }
github dcfjs / dcf / src / master / loaders / fileLoader.ts View on Github external
async function rmdirs(basePath: string) {
  const stat = await fs.lstat(basePath);
  if (stat.isDirectory()) {
    const contents = await fs.readdir(basePath);
    for (const file of contents) {
      await rmdirs(path.resolve(basePath, file));
    }
  } else {
    await fs.unlink(basePath);
  }
}

fs-promise

[DEPRECATED] Use mz or fs-extra^3.0 with Promise Support

MIT
Latest version published 7 years ago

Package Health Score

50 / 100
Full package analysis