Skip to content

Commit

Permalink
Pass deep option to ignore filter to avoid unnecessary recursion (#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
fwouts authored Jun 18, 2023
1 parent 863ec4a commit a0e4028
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ignore.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ const getIsIgnoredPredicate = (files, cwd) => {
const normalizeOptions = (options = {}) => ({
cwd: toPath(options.cwd) || process.cwd(),
suppressErrors: Boolean(options.suppressErrors),
deep: typeof options.deep === 'number' ? options.deep : Number.POSITIVE_INFINITY,
});

export const isIgnoredByIgnoreFiles = async (patterns, options) => {
const {cwd, suppressErrors} = normalizeOptions(options);
const {cwd, suppressErrors, deep} = normalizeOptions(options);

const paths = await fastGlob(patterns, {cwd, suppressErrors, ...ignoreFilesGlobOptions});
const paths = await fastGlob(patterns, {cwd, suppressErrors, deep, ...ignoreFilesGlobOptions});

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

export const isIgnoredByIgnoreFilesSync = (patterns, options) => {
const {cwd, suppressErrors} = normalizeOptions(options);
const {cwd, suppressErrors, deep} = normalizeOptions(options);

const paths = fastGlob.sync(patterns, {cwd, suppressErrors, ...ignoreFilesGlobOptions});
const paths = fastGlob.sync(patterns, {cwd, suppressErrors, deep, ...ignoreFilesGlobOptions});

const files = paths.map(filePath => ({
filePath,
Expand Down

0 comments on commit a0e4028

Please sign in to comment.