How to use minimatch

Comprehensive minimatch code examples:

How to use minimatch.match:

246
247
248
249
250
251
252
253
254
255
    core.debug(`rooted pattern: '${pattern}'`);
}
if (isIncludePattern) {
    // apply the pattern
    core.debug('applying include pattern against original list');
    let matchResults = minimatch.match(list, pattern, options);
    core.debug(matchResults.length + ' matches');
    // union the results
    for (let matchResult of matchResults) {
        map[matchResult] = true;

How to use minimatch.filter:

18
19
20
21
22
23
24
25
26
27
28
29
 */
const matchesFilter = (asset, pattern) => {
    const relativeToRoot = path.relative(process.cwd(), asset.absolutePath);


    if (typeof pattern === 'string') {
        pattern = minimatch.filter(pattern);


        return pattern(relativeToRoot);
    }

How to use minimatch.makeRe:

54
55
56
57
58
59
60
61
62
63
  .add('minimatch', () => minimatch.braceExpand('foo/{1..250}/bar'))
  .run();

bench('expand - range (optimized for regex)')
  .add('   braces', () => braces.compile('foo/{1..250}/bar'))
  .add('minimatch', () => minimatch.makeRe('foo/{1..250}/bar'))
  .run();

bench('expand - nested ranges (expanded)')
  .add('   braces', () => braces.expand('foo/{a,b,{1..250}}/bar'))

How to use minimatch.braceExpand:

49
50
51
52
53
54
55
56
57
58
  return skip;
};

bench('expand - range (expanded)')
  .add('   braces', () => braces.expand('foo/{1..250}/bar'))
  .add('minimatch', () => minimatch.braceExpand('foo/{1..250}/bar'))
  .run();

bench('expand - range (optimized for regex)')
  .add('   braces', () => braces.compile('foo/{1..250}/bar'))

How to use minimatch.default:

29
30
31
32
33
34
35
36
37
38
const includedGlobPatterns = resolveFileGlobPatterns(configuration.files);
const includedFiles = new Set();
function isFileIncluded(path) {
    return __awaiter(this, void 0, void 0, function* () {
        return (!path.includes('node_modules') &&
            includedGlobPatterns.some((pattern) => minimatch_1.default(path, pattern)) &&
            !(yield eslint.isPathIgnored(path)));
    });
}
function getFiles() {

How to use minimatch.GLOBSTAR:

353
354
355
356
357
358
359
360
361
362

//if ignored, skip _processing
if (childrenIgnored(this, read))
  return cb()

var isGlobStar = remain[0] === minimatch.GLOBSTAR
if (isGlobStar)
  this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb)
else
  this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb)

How to use minimatch.Minimatch:

196
197
198
199
200
201
202
203
204
205
  delete options.noglobstar
}
if (params.anchored == false) { options.matchBase = true }
if (params.debug == 'minimatch') { options.debug = true }

const mm = new minimatch.Minimatch(params.pattern, options)
if (!mm.makeRe()) { // Bad pattern
  throw Object.assign(
    new Error(`Invalid match pattern "${params.origPattern}"`),
    { code: 'EINVAL', pattern: params.origPattern }