diff --git a/packages/svelte-check/package.json b/packages/svelte-check/package.json index 9d8309c46..4e1de5f67 100644 --- a/packages/svelte-check/package.json +++ b/packages/svelte-check/package.json @@ -25,6 +25,7 @@ "dependencies": { "@jridgewell/trace-mapping": "^0.3.17", "chokidar": "^3.4.1", + "fdir": "^6.1.1", "picocolors": "^1.0.0", "sade": "^1.7.4", "svelte-preprocess": "^5.1.3", @@ -46,7 +47,6 @@ "@rollup/plugin-typescript": "^10.0.0", "@types/sade": "^1.7.2", "builtin-modules": "^3.3.0", - "fast-glob": "^3.2.7", "rollup": "3.7.5", "rollup-plugin-cleanup": "^3.2.0", "rollup-plugin-copy": "^3.4.0", diff --git a/packages/svelte-check/src/index.ts b/packages/svelte-check/src/index.ts index 6e64414ed..dde7bdcdc 100644 --- a/packages/svelte-check/src/index.ts +++ b/packages/svelte-check/src/index.ts @@ -4,7 +4,7 @@ import { watch } from 'chokidar'; import * as fs from 'fs'; -import glob from 'fast-glob'; +import { fdir } from 'fdir'; import * as path from 'path'; import { SvelteCheck, SvelteCheckOptions } from 'svelte-language-server'; import { Diagnostic, DiagnosticSeverity } from 'vscode-languageserver-protocol'; @@ -30,10 +30,20 @@ async function openAllDocuments( filePathsToIgnore: string[], svelteCheck: SvelteCheck ) { - const files = await glob('**/*.svelte', { - cwd: workspaceUri.fsPath, - ignore: ['node_modules/**'].concat(filePathsToIgnore.map((ignore) => `${ignore}/**`)) - }); + const ignored = ['node_modules'].concat(filePathsToIgnore); + const isIngored = (path: string) => { + for (const i of ignored) { + if (path.startsWith(i)) { + return false; + } + return true; + } + }; + const files = await new fdir() + .withBasePath() + .filter((path) => path.endsWith('.svelte') && !isIngored(path)) + .crawl(workspaceUri.fsPath) + .withPromise(); const absFilePaths = files.map((f) => path.resolve(workspaceUri.fsPath, f)); for (const absFilePath of absFilePaths) { diff --git a/packages/svelte-check/src/options.ts b/packages/svelte-check/src/options.ts index bf270e3c4..aa5e8e6c1 100644 --- a/packages/svelte-check/src/options.ts +++ b/packages/svelte-check/src/options.ts @@ -73,7 +73,7 @@ export function parseOptions(cb: (opts: SvelteCheckCliOptions) => any) { watch: !!opts.watch, preserveWatchOutput: !!opts.preserveWatchOutput, tsconfig: getTsconfig(opts, workspaceUri.fsPath), - filePathsToIgnore: getFilepathsToIgnore(opts), + filePathsToIgnore: opts.ignore?.split(',') || [], failOnWarnings: !!opts['fail-on-warnings'], compilerWarnings: getCompilerWarnings(opts), diagnosticSources: getDiagnosticSources(opts), @@ -180,10 +180,6 @@ function getDiagnosticSources(opts: Record): DiagnosticSource[] { : diagnosticSources; } -function getFilepathsToIgnore(opts: Record): string[] { - return opts.ignore?.split(',') || []; -} - const thresholds = ['warning', 'error'] as const; type Threshold = (typeof thresholds)[number]; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7aad93cbe..3d2faa720 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -121,6 +121,9 @@ importers: chokidar: specifier: ^3.4.1 version: 3.5.3 + fdir: + specifier: ^6.1.1 + version: 6.1.1 picocolors: specifier: ^1.0.0 version: 1.0.0 @@ -158,9 +161,6 @@ importers: builtin-modules: specifier: ^3.3.0 version: 3.3.0 - fast-glob: - specifier: ^3.2.7 - version: 3.2.12 rollup: specifier: 3.7.5 version: 3.7.5 @@ -745,6 +745,14 @@ packages: fastq@1.15.0: resolution: {integrity: sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==} + fdir@6.1.1: + resolution: {integrity: sha512-QfKBVg453Dyn3mr0Q0O+Tkr1r79lOTAKSi9f/Ot4+qVEwxWhav2Z+SudrG9vQjM2aYRMQQZ2/Q1zdA8ACM1pDg==} + peerDependencies: + picomatch: 3.x + peerDependenciesMeta: + picomatch: + optional: true + fill-range@7.0.1: resolution: {integrity: sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==} engines: {node: '>=8'} @@ -1818,6 +1826,8 @@ snapshots: dependencies: reusify: 1.0.4 + fdir@6.1.1: {} + fill-range@7.0.1: dependencies: to-regex-range: 5.0.1