From 32a5fce5e766c0c1b55dcdd943e2f5ab71902921 Mon Sep 17 00:00:00 2001 From: Torathion Date: Thu, 20 Feb 2025 14:34:16 +0100 Subject: [PATCH] add and optimize changes from 0.2.12 --- src/fdir.ts | 4 ++-- src/utils.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/fdir.ts b/src/fdir.ts index a4b22ba..795bbb3 100644 --- a/src/fdir.ts +++ b/src/fdir.ts @@ -61,8 +61,8 @@ export function buildFdir(options: GlobOptions, props: InternalProps, processed: exclude: (_, p) => { const relativePath = processPath(p, cwd, root, true, true); const skipped = (relativePath !== '.' && !partialMatcher(relativePath)) || ignore(relativePath); - if (debug && !skipped) { - log(`crawling ${p}`); + if (debug) { + log(`${skipped ? 'skipped' : 'crawling'} ${p}`); } return skipped; }, diff --git a/src/utils.ts b/src/utils.ts index f3dc4ee..de47935 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -20,16 +20,16 @@ export function getPartialMatcher(patterns: string[], options?: PartialMatcherOp regexes[i] = partRegexes; } return (input: string) => { - // no need to `splitPattern` as this is indeed not a pattern - const inputParts = input.split('/'); // if we only have patterns like `src/*` but the input is `../..` // normally the parent directory would not get crawled // and as such wrong results would be returned // to avoid this always return true if the input only consists of .. ../.. etc - if (inputParts[0] === '..' && ONLY_PARENT_DIRECTORIES.test(input)) { + if (input.startsWith('..') && ONLY_PARENT_DIRECTORIES.test(input)) { return true; } - for (let i = 0; i < patterns.length; i++) { + // no need to `splitPattern` as this is indeed not a pattern + const inputParts = input.split('/'); + for (let i = 0; i < patternsCount; i++) { const patternParts = patternsParts[i]; const regex = regexes[i]; const inputPatternCount = inputParts.length;