Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass deep option to ignore filter to avoid unnecessary recursion #251

Merged
merged 2 commits into from
Jun 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions ignore.js
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