fs#readdir JavaScript Examples

The following examples show how to use fs#readdir. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.js    From ucompress with ISC License 6 votes vote down vote up
crawl = (source, options) => new Promise((res, rej) => {
  stat(source, (err, stat) => {
    /* istanbul ignore if */
    if (err)
      rej(err);
    else {
      if (stat.isFile())
        copy(source, source, options).then(res, rej);
      /* istanbul ignore else */
      else if (stat.isDirectory())
        readdir(source, (err, files) => {
          /* istanbul ignore if */
          if (err)
            rej(err);
          else
            Promise.all(files
              .filter(file => !/^[._]/.test(file))
              .map(file => crawl(join(source, file), options))
            ).then(res, rej);
        });
    }
  });
})
Example #2
Source File: index.js    From watchlist with MIT License 5 votes vote down vote up
toRead = promisify(readdir)
Example #3
Source File: async-folder.js    From nanoexpress with Apache License 2.0 5 votes vote down vote up
fsReadDir = promisify(readdir)