Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (res.some(re => re.test(context.filename))) return true;
if (fns.some(fn => fn(filename))) return true;
if (strings.length > 0) {
const possibleDirs = getPossibleDirs(context);
const absolutePatterns = strings.map(pattern => {
// Preserve the "!" prefix so that micromatch can use it for negation.
const negate = pattern[0] === "!";
if (negate) pattern = pattern.slice(1);
return (negate ? "!" : "") + path.resolve(dirname, pattern);
});
if (
micromatch(possibleDirs, absolutePatterns, { nocase: true }).length > 0
) {
return true;
}
}
return false;
}
test('match glob pattern', () => {
expect(mm(paths, '**')).toEqual(paths);
expect(mm(paths, '*')).toEqual(['a']);
expect(mm(paths, 'a/*')).toEqual(['a/b', 'a/d']);
expect(mm(paths, 'a/**')).toEqual(['a/b', 'a/b/c', 'a/b/c/d', 'a/d']);
expect(mm(paths, '*/a')).toEqual(['d/a']);
expect(mm(paths, '**/a')).toEqual(['a', 'd/a', 'e/d/a']);
expect(mm(paths, '*/a/*')).toEqual(['d/a/e']);
expect(mm(paths, '**/a/**')).toEqual(['a/b', 'a/b/c', 'a/b/c/d', 'a/d', 'd/a/e', 'd/a/e/b']);
});
});
test('match explicit path', () => {
expect(mm(paths, 'a')).toEqual(['a']);
expect(mm(paths, 'b/c')).toEqual(['b/c']);
expect(mm(paths, 'd')).toEqual([]);
expect(mm(paths, 'a/b')).toEqual(['a/b']);
});
test('match glob pattern', () => {
test('match glob pattern', () => {
expect(mm(paths, '**')).toEqual(paths);
expect(mm(paths, '*')).toEqual(['a']);
expect(mm(paths, 'a/*')).toEqual(['a/b', 'a/d']);
expect(mm(paths, 'a/**')).toEqual(['a/b', 'a/b/c', 'a/b/c/d', 'a/d']);
expect(mm(paths, '*/a')).toEqual(['d/a']);
expect(mm(paths, '**/a')).toEqual(['a', 'd/a', 'e/d/a']);
expect(mm(paths, '*/a/*')).toEqual(['d/a/e']);
expect(mm(paths, '**/a/**')).toEqual(['a/b', 'a/b/c', 'a/b/c/d', 'a/d', 'd/a/e', 'd/a/e/b']);
});
});
test('match glob pattern', () => {
expect(mm(paths, '**')).toEqual(paths);
expect(mm(paths, '*')).toEqual(['a']);
expect(mm(paths, 'a/*')).toEqual(['a/b', 'a/d']);
expect(mm(paths, 'a/**')).toEqual(['a/b', 'a/b/c', 'a/b/c/d', 'a/d']);
expect(mm(paths, '*/a')).toEqual(['d/a']);
expect(mm(paths, '**/a')).toEqual(['a', 'd/a', 'e/d/a']);
expect(mm(paths, '*/a/*')).toEqual(['d/a/e']);
expect(mm(paths, '**/a/**')).toEqual(['a/b', 'a/b/c', 'a/b/c/d', 'a/d', 'd/a/e', 'd/a/e/b']);
});
});
const expectFileToMatchPatterns = (file, patterns) => {
const matches = micromatch([file], patterns);
expect(matches).toEqual([file]);
};
globs.map(glob => {
const handler = transforms[glob]
const filepaths = match(stream.fileList, glob)
return Promise.all(
filepaths.map(filepath => {
return handler(filepath, stream)
})
)
})
)
export function skip({ignore, only}, file) {
if (only) {
return micromatch(
[file],
Array.isArray(only) ? only : [only],
{nocase: true}
).length <= 0;
}
if (ignore) {
return micromatch(
[file],
Array.isArray(ignore) ? ignore : [ignore],
{nocase: true}
).length > 0;
}
return false;
}