file-set
Expands a list of paths and glob expressions into three sets: "files", "directories" and "not existing". Each set in the output is a list of unique paths.
The library saves you the job of learning a globbing library, expanding a glob expression (e.g. lib/**/*), sifting through each result testing whether it's a file, directory or neither.
Usage
Expand two glob expressions ('*' and 'not/existing/*').
import FileSet from 'file-set'
const fileSet = new FileSet()
await fileSet.add([ '*', 'not/existing/*' ])
console.log(fileSet)
The output has been organised into sets.
FileSet {
files: [ 'LICENSE', 'package.json', 'README.md' ],
dirs: [ 'jsdoc2md/', 'lib/', 'node_modules/', 'test/' ],
notExisting: [ 'not/existing/*' ]
}
API
file-set
-
file-set
-
FileSet
⏏ - new FileSet()
-
.files :
Array.<string> -
.dirs :
Array.<string> -
.notExisting :
Array.<string> - .add(files)
-
FileSet
FileSet ⏏
new FileSet()
fileSet.files : Array.<string>
The existing files found
Kind: instance property of FileSet
fileSet.dirs : Array.<string>
The existing directories found. Directory paths will always end with '/'.
Kind: instance property of FileSet
fileSet.notExisting : Array.<string>
Paths which were not found
Kind: instance property of FileSet
fileSet.add(patterns)
Add file patterns to the set.
Kind: instance method of FileSet
| Param | Type | Description |
|---|---|---|
| patterns |
string \ |
Array.<string> |
Tested by test-runner.