Skip to content

Commit

Permalink
Pass deep option to ignore filter to avoid unnecessary recursion
Browse files Browse the repository at this point in the history
  • Loading branch information
fwouts committed Jun 15, 2023
1 parent 863ec4a commit d93fa14
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: options.deep ? Number.parseInt(options.deep, 10) : 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 d93fa14

Please sign in to comment.