From a0e4028c5daf199b9d20ce9027a8af383fc084c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Wouts?= Date: Mon, 19 Jun 2023 04:24:40 +1000 Subject: [PATCH] Pass deep option to ignore filter to avoid unnecessary recursion (#251) --- ignore.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ignore.js b/ignore.js index 73c9a52..3d8e1a8 100644 --- a/ignore.js +++ b/ignore.js @@ -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 => ({ @@ -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,