From df87341a7b4b61f4ef809988c5ae27a4c7405b72 Mon Sep 17 00:00:00 2001 From: Ramalingareddy1 Date: Tue, 22 Oct 2024 20:00:25 +0530 Subject: [PATCH] Improve matchPathFilter to handle mixed arrays of string and glob paths --- src/path-filter.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/path-filter.ts b/src/path-filter.ts index 777fa5f4..24876d37 100644 --- a/src/path-filter.ts +++ b/src/path-filter.ts @@ -22,13 +22,22 @@ export function matchPathFilter( // multi path if (Array.isArray(pathFilter)) { - if (pathFilter.every(isStringPath)) { + const stringPaths = pathFilter.filter(isStringPath); + const globPaths = pathFilter.filter(isGlobPath); + + // Handle mixed arrays + if (stringPaths.length && globPaths.length) { + return ( + matchMultiPath(stringPaths, uri) || + matchMultiGlobPath(globPaths, uri) + ); + } + if (stringPaths.length) { return matchMultiPath(pathFilter, uri); } - if (pathFilter.every(isGlobPath)) { - return matchMultiGlobPath(pathFilter as string[], uri); + if (globPaths.length) { + return matchMultiGlobPath(pathFilter, uri); } - throw new Error(ERRORS.ERR_CONTEXT_MATCHER_INVALID_ARRAY); }