readdirrec
Module for deep directory listing
- Choose if it should be just files, or folders, or both
- Turn off recursion if needed
- Return results with relative path
- Use it both synchronous or asynchronous version
Installation
npm install readdirrec
API
await
path
Type: String
options.files_only
Type: Boolean
Default: true
Find files only
options.folders_only
Type: Boolean
Default: false
Find folders only
options.recursive
Type: Boolean
Default: true
If false
then path
would be the only level for search
options.relative
Type: Boolean
Default: false
Cut the path
from the results
options.filter
Type: Function | Object
Usage
const rdr = ; // Cut root_dir part from path of each file/folderawait // Get folders onlyawait // Get both files ond folderawait // Different filtersawait // => ['config.js'] await // => ['file1.js', 'file2.js'] await // => ['file1.js', 'file2.js', 'archive.zip']
Changelog
v3.0.0 (2020-09-04):
- removed synchronous version
- removed
try/catch
wrapper, so now module throws all exceptions as it should be - fixed a bunch of different bugs
Related
More advanced modules: