Skip to content

Commit a0e4028

Browse files
authored
Pass deep option to ignore filter to avoid unnecessary recursion (#251)
1 parent 863ec4a commit a0e4028

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

ignore.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,13 @@ const getIsIgnoredPredicate = (files, cwd) => {
5959
const normalizeOptions = (options = {}) => ({
6060
cwd: toPath(options.cwd) || process.cwd(),
6161
suppressErrors: Boolean(options.suppressErrors),
62+
deep: typeof options.deep === 'number' ? options.deep : Number.POSITIVE_INFINITY,
6263
});
6364

6465
export const isIgnoredByIgnoreFiles = async (patterns, options) => {
65-
const {cwd, suppressErrors} = normalizeOptions(options);
66+
const {cwd, suppressErrors, deep} = normalizeOptions(options);
6667

67-
const paths = await fastGlob(patterns, {cwd, suppressErrors, ...ignoreFilesGlobOptions});
68+
const paths = await fastGlob(patterns, {cwd, suppressErrors, deep, ...ignoreFilesGlobOptions});
6869

6970
const files = await Promise.all(
7071
paths.map(async filePath => ({
@@ -77,9 +78,9 @@ export const isIgnoredByIgnoreFiles = async (patterns, options) => {
7778
};
7879

7980
export const isIgnoredByIgnoreFilesSync = (patterns, options) => {
80-
const {cwd, suppressErrors} = normalizeOptions(options);
81+
const {cwd, suppressErrors, deep} = normalizeOptions(options);
8182

82-
const paths = fastGlob.sync(patterns, {cwd, suppressErrors, ...ignoreFilesGlobOptions});
83+
const paths = fastGlob.sync(patterns, {cwd, suppressErrors, deep, ...ignoreFilesGlobOptions});
8384

8485
const files = paths.map(filePath => ({
8586
filePath,

0 commit comments

Comments
 (0)