Recursively list all files and directories within a target directory.
Similar to recursive-readdir but it includes paths of subdirectories in the files list (and it returns a Promise instead of using a callback).
Installation using Yarn is recommended.
yarn add @frctl/readr
readr
returns a Promise
that is resolved with an array of file/directory paths.
const readr = require('@frctl/readr');
readr('path/to/files').then(files => {
// do something with the files list.
});
You can also provide a filter function to ignore certain files:
const readr = require('@frctl/readr');
const filter = (path, stat) => stat.isFile(); // filter out directories
readr('path/to/files', filter).then(files => {
console.log(files); // no directories here!
});
@frctl/readr
requires Node >= v6.0