From 5c98c9d0d445a50503a6be44450550f50271bc23 Mon Sep 17 00:00:00 2001 From: Simon Holthausen Date: Mon, 19 Aug 2024 17:58:29 +0200 Subject: [PATCH] fix pattern syntax --- packages/svelte-check/src/index.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/svelte-check/src/index.ts b/packages/svelte-check/src/index.ts index 2ba51da54..7e04373a7 100644 --- a/packages/svelte-check/src/index.ts +++ b/packages/svelte-check/src/index.ts @@ -31,21 +31,26 @@ async function openAllDocuments( svelteCheck: SvelteCheck ) { const offset = workspaceUri.fsPath.length + 1; - // We support a very limited subset of glob patterns: You can have a * at the end or the start + // We support a very limited subset of glob patterns: You can only have ** at the end or the start const ignored: Array<(path: string) => boolean> = filePathsToIgnore.map((i) => { - if (i.endsWith('*')) i = i.slice(0, -1); - if (i.startsWith('*')) { - i = i.slice(1); + if (i.endsWith('**')) i = i.slice(0, -2); + + if (i.startsWith('**')) { + i = i.slice(2); + if (i.includes('*')) throw new Error( - 'Invalid svelte-check --ignore pattern: Only * at the start or end is supported' + 'Invalid svelte-check --ignore pattern: Only ** at the start or end is supported' ); + return (path) => path.includes(i); } + if (i.includes('*')) throw new Error( - 'Invalid svelte-check --ignore pattern: Only * at the start or end is supported' + 'Invalid svelte-check --ignore pattern: Only ** at the start or end is supported' ); + return (path) => path.startsWith(i); }); const isIngored = (path: string) => {