gemini-testing / gemini-testing/glob-extra
Throw error or warning if path do not match any file.
- Dominant language
- JavaScript
- Stars
- 0
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
## Problem:
If we pass array with one or more invalid `path` they just just skipped. It may be an issue because after calling `require('glob-extra').expandPaths` we don't know how many paths are not valid or is there any?
## Example:
const paths = getArrayFromUserInput(); // ['./right/path/but/with/typoo/5.js', './path/that/do/not/exist/1.js', './path/to/two/or/three/files/*'];
const resolved = require('glob-extra').expandPaths()paths;
functionThatUserExpectsWorkOnFiveLinksButWorksOnFour(paths);
## Solution:
Make new option `options.errorOnNoMatch` that will throw error it any of array's path do not match file.
```
// glob-extra/lib/index.js:11
const getFilesByMask = (pattern, options) => {
const files = fg.sync(pattern, options);
if (options.errorOnNoMatch && files.length == 0) {
throw new Error('Could not match any files with given patten: ' + pattern);
}
return Promise.resolve(files);
};
```
Contributor guide
Assessment
This issue has not been assessed yet.