scandirectory
![Dev Dependency Status](https://img.shields.io/david/dev/bevry/scandirectory.svg)
![Wishlist browse button](https://img.shields.io/badge/wishlist-donate-yellow.svg)
Scan a directory recursively with a lot of control and power
Install
- Use:
require('scandirectory')
- Install:
npm install --save scandirectory
Usage
- `scandir(path, opts, next?)``
- `scandir(opts, next?)``
Options:
path
: the path you want to readaction
: (default null) can be null or a function to use for both the fileAction and dirActionfileAction
: (default null) can be null or a function to run against each file, in the following format:
- `fileAction(fileFullPath, fileRelativePath, next(err,skip), fileStat)``
dirAction
: (default null) can be null or a function to run against each directory, in the following format:
- `dirAction(fileFullPath, fileRelativePath, next(err,skip), fileStat)``
next
: (default null) can be null or a function to run after the entire directory has been scanned, in the following format:
stat
: (default null) can be null or a file stat object for the path if we already have one (not actually used yet)recurse
: (default true) can be null or a boolean for whether or not to scan subdirectories tooreadFiles
: (default false) can be null or a boolean for whether or not we should read the file contentsignorePaths
: (default false) can be null or an array of paths that we should ignoreignoreHiddenFiles
: (default false) can be null or a boolean for if we should ignore files starting with a dotignoreCommonPatterns
: (default false) can be null or a boolean or a regex
- if null, becomes true
- if false, does not do any ignore patterns
- if true, defaults to bevry/ignorepatterns
- if regex, uses this value instead of bevry/ignorepatterns
ignoreCustomPatterns
: (default false) can be null or a boolean or a regex (same as ignoreCommonPatterns but for ignoreCustomPatterns instead)
Next Callback Arguments:
err
: null, or an error that has occuredlist
: a collection of all the child nodes in a list/object format:
{fileRelativePath: 'dir|file'}
tree
: a colleciton of all the child nodes in a tree format:
{dir: {dir:{}, file1:true} }
- if the readFiles option is true, then files will be returned with their contents instead
Contribute
Discover how you can contribute by heading on over to the CONTRIBUTING.md
file.
History
Discover the change history by heading on over to the HISTORY.md
file.
Backers
Maintainers
These amazing people are maintaining this project:
No sponsors yet! Will you be the first?
![Wishlist browse button](https://img.shields.io/badge/wishlist-donate-yellow.svg)
Contributors
These amazing people have contributed code to this project:
Become a contributor!
License
Licensed under the incredibly permissive MIT license
Copyright © 2011+ Benjamin Lupton b@lupton.cc (http://balupton.com)
Copyright © 2014+ Bevry Pty Ltd us@bevry.me (http://bevry.me)