Package Exports
- deep-list-dir
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (deep-list-dir) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
deep-list-dir
Deeply lists a directory filtering files by given pattern(s)
This module recursively lists all files in given directory (including sub-folders) by early filtering the results using the
given pattern
which can be an array of minimatch
expressions or RegExp
.
It will return all matching results. minimatch negative patterns are used to explicitly exclude a path from being scan / returned.
Example
Take the following file structure:
<directory>
├── dir1
│ └── README.md
├── dir2
│ └── sub-dir2
│ ├── hi.txt
│ └── index.js
├── index.js
└── README.md
...and the following script:
const { deepListDir, deepListDirSync } = require('deep-list-dir')
deepListDir('<directory>',
{
pattern: ['*.md'], // minimatch or RegExp
// base: '', set parent base to something different than given directory
// minimatchOptions: { matchBase: true } // minimatch options
}
).then(console.log)
Will output
[
"dir1/README.md",
"README.md"
]
A sync version is also provided:
console.log(deepListDirSync('<directory>', { pattern: '*.js'}))
Output:
[
"dir2/sub-dir2/index.js",
"index.js"
]
License
© 2020-present Martin Rafael Gonzalez tin@devtin.io