https://github.com/75lb/file-set
Expand a list of paths and glob expressions into three sets: "files", "directories" and "not existing".
https://github.com/75lb/file-set
glob
Last synced: 9 months ago
JSON representation
Expand a list of paths and glob expressions into three sets: "files", "directories" and "not existing".
- Host: GitHub
- URL: https://github.com/75lb/file-set
- Owner: 75lb
- License: mit
- Created: 2014-06-02T22:04:32.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2022-01-14T21:53:19.000Z (over 4 years ago)
- Last Synced: 2024-04-14T12:17:12.034Z (over 2 years ago)
- Topics: glob
- Language: JavaScript
- Homepage:
- Size: 230 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://www.npmjs.org/package/file-set)
[](https://www.npmjs.org/package/file-set)
[](https://github.com/75lb/file-set/network/dependents?dependent_type=REPOSITORY)
[](https://github.com/75lb/file-set/network/dependents?dependent_type=PACKAGE)
[](https://github.com/75lb/file-set/actions/workflows/node.js.yml)
# file-set
Cross-platform glob expansions simplified. Input: file paths and glob expressions. Output: resolved file paths organised by type (file, directory and not-found). It handles all the cross-platform issues associated with file paths.
Particularly useful for handling user input, for example a CLI utility which accepts a list of file paths and globs.
```
$ example-utility index.js * not/existing/*
```
The example-utility above could pass its user input into `FileSet`. Call `await .add()` as many times as necessary, adding more path/glob expressions each time.
```js
import FileSet from 'file-set'
const fileSet = new FileSet()
await fileSet.add([ 'index.js', '*', 'not/existing/*' ])
console.log(fileSet)
```
The output has been organised into sets. Any duplicates caused by overlapping glob expressions are removed.
```
FileSet {
files: [ 'index.js', 'LICENSE', 'package.json', 'README.md' ],
dirs: [ 'jsdoc2md/', 'lib/', 'node_modules/', 'test/' ],
notExisting: [ 'not/existing/*' ]
}
```
* * *
© 2014-25 [Lloyd Brookes](https://github.com/75lb) \.