Collect the descendants of a directory.
// Create a crawl function.// These are the default options.// The result is an array when `follow` is false, else an object.// Provide your own array/object.crawlroot, files// Provide an iterator.crawlroot,
You can use the
crawl() export if you don't want to reuse the configured crawler.
skip options should be self-explanatory. Paths matching any of
only patterns are good. When
only is an empty array, all paths are good.
Paths matching any of the
skip patterns are bad. When
skip is an empty
array, no paths are bad. The
skip patterns override the
To avoid crawling sub-directories, set
deep to false or
depth to 0. You
should never define both
depth, because the
depth option implies
deep when it's greater than zero. If neither
depth are defined,
the default depth is infinite.
enter option is called whenever a directory is encountered. It's passed
the directory path and the current depth. You may return a falsy value to avoid
crawling a directory.
filter option is called whenever a filename is encountered. It's passed
the filename and its basename. You may return a falsy value to skip a filename.
skip options are applied before this option is called.
To follow all symlinks, set
follow to true. For greater control, use a
function. It's called whenever a symlink is encountered. You may return a falsy
value to avoid following a symlink. It's passed the symlink path and the current
link depth. If you only need to limit the link depth, you can set
follow to a
number, where zero is equivalent to false.
adapter option lets you provide your own filesystem.
- Directory symlinks are treated the same as real directories
- Directories are not affected by the
Recrawl has its own take on globbing.
- When a path has no separators (
/), only the basename is matched.
'*.js' // matches 'a.js' and 'a/b.js'
- Recursivity is implicit.
'a/b' // identical to '**/a/b'
- Use a leading separator to match against the root.
'/*.js' // matches 'a.js' not 'a/b.js'
- Use a trailing separator to match all descendants.
'foo/' // matches 'foo/bar' and 'foo/bar/baz' etc
- Regular expression syntax is supported. (except dot-all)
'*.jsx?' // matches 'a.js' and 'b.jsx''*.(js|ts)' // matches 'a.js' and 'b.ts'
- Recursive globbing is supported.
'foo/**/bar' // matches 'foo/bar' and 'foo/a/b/c/bar' etc