Recursively walk file system tree and callback on every file
API is stable.
npm install walk-folder-tree
var walk = ;
walk(path [, options] [, fn])
Recursively walks through the directory tree from
path downwards, calling
fn on every file and directory.
fn is called with the single argument
params is of the form:
path: /* path relative to root path */fullPath: /* full path of file */name: /* filename of file */directory: /* true if is a directory */stat: /* stat object for the file (as returned from `fs.stat()`) */
walk() returns a promise.
fn can also be provided as attributes of
fn can alternatively be a promise-returning function. Just leave off the callback argument.
fn can also be a generator. If so, it is wrapped using co so you can
true, recurses through subfolders and sub-subfolders, examining an entire tree. Set to
false to ignore subfolders.
A regular expression for what files to include.
/^[^.]/ (i.e. ignore files starting with
// include all files;
A regular expression for what folders to iterate into.
/^[^.]/ (i.e. process all folders except those beginning with
// Process all folders except those starting with `.` or `_`;
If set to
true, returns an array of all files and folders found.
Function to sort files in each folder before processing.
npm test to run the tests. Use
npm run cover to check coverage.
If you discover a bug, please raise an issue on Github. https://github.com/overlookmotel/walk-folder-tree/issues
Pull requests are very welcome. Please:
- ensure all tests pass before submitting PR
- add an entry to changelog
- add tests for new features
- document new functionality/API additions in README