Exclude files using negation patterns
mainYou can exclude files from your results using negation patterns (starting with !). There are two ways to implement this:
1. With positive patterns: Include positive patterns followed by negation patterns to filter the results.
2. Negation-only patterns:
If you provide only negation patterns, globby implicitly prepends **/* to match all files before applying the negations. For example, ['!*.json', '!*.xml'] is equivalent to ['**/*', '!*.json', '!*.xml'].
Note: The implicit **/* pattern respects the dot option. By default, dotfiles (files starting with .) are not matched unless you set dot: true in the options.
// Matches all .js files except test files
await globby(['src/**/*.js', '!src/**/*.test.js']);
// Matches all files in config/ except .json and .xml files
await globby(['!*.json', '!*.xml'], {cwd: 'config'});