Skip to content

Commit 0e15f94

Browse files
committed
chore: switch from fast-glob to fdir
1 parent 00212c4 commit 0e15f94

File tree

4 files changed

+30
-14
lines changed

4 files changed

+30
-14
lines changed

packages/svelte-check/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"dependencies": {
2626
"@jridgewell/trace-mapping": "^0.3.17",
2727
"chokidar": "^3.4.1",
28+
"fdir": "^6.1.1",
2829
"picocolors": "^1.0.0",
2930
"sade": "^1.7.4",
3031
"svelte-preprocess": "^5.1.3",
@@ -46,7 +47,6 @@
4647
"@rollup/plugin-typescript": "^10.0.0",
4748
"@types/sade": "^1.7.2",
4849
"builtin-modules": "^3.3.0",
49-
"fast-glob": "^3.2.7",
5050
"rollup": "3.7.5",
5151
"rollup-plugin-cleanup": "^3.2.0",
5252
"rollup-plugin-copy": "^3.4.0",

packages/svelte-check/src/index.ts

+15-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import { watch } from 'chokidar';
66
import * as fs from 'fs';
7-
import glob from 'fast-glob';
7+
import { fdir } from 'fdir';
88
import * as path from 'path';
99
import { SvelteCheck, SvelteCheckOptions } from 'svelte-language-server';
1010
import { Diagnostic, DiagnosticSeverity } from 'vscode-languageserver-protocol';
@@ -30,10 +30,20 @@ async function openAllDocuments(
3030
filePathsToIgnore: string[],
3131
svelteCheck: SvelteCheck
3232
) {
33-
const files = await glob('**/*.svelte', {
34-
cwd: workspaceUri.fsPath,
35-
ignore: ['node_modules/**'].concat(filePathsToIgnore.map((ignore) => `${ignore}/**`))
36-
});
33+
const ignored = ['node_modules'].concat(filePathsToIgnore);
34+
const isIngored = (path: string) => {
35+
for (const i of ignored) {
36+
if (path.startsWith(i)) {
37+
return true;
38+
}
39+
}
40+
return false;
41+
};
42+
const files = await new fdir()
43+
.withBasePath()
44+
.filter((path) => path.endsWith('.svelte') && !isIngored(path))
45+
.crawl(workspaceUri.fsPath)
46+
.withPromise();
3747
const absFilePaths = files.map((f) => path.resolve(workspaceUri.fsPath, f));
3848

3949
for (const absFilePath of absFilePaths) {

packages/svelte-check/src/options.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export function parseOptions(cb: (opts: SvelteCheckCliOptions) => any) {
7373
watch: !!opts.watch,
7474
preserveWatchOutput: !!opts.preserveWatchOutput,
7575
tsconfig: getTsconfig(opts, workspaceUri.fsPath),
76-
filePathsToIgnore: getFilepathsToIgnore(opts),
76+
filePathsToIgnore: opts.ignore?.split(',') || [],
7777
failOnWarnings: !!opts['fail-on-warnings'],
7878
compilerWarnings: getCompilerWarnings(opts),
7979
diagnosticSources: getDiagnosticSources(opts),
@@ -180,10 +180,6 @@ function getDiagnosticSources(opts: Record<string, any>): DiagnosticSource[] {
180180
: diagnosticSources;
181181
}
182182

183-
function getFilepathsToIgnore(opts: Record<string, any>): string[] {
184-
return opts.ignore?.split(',') || [];
185-
}
186-
187183
const thresholds = ['warning', 'error'] as const;
188184
type Threshold = (typeof thresholds)[number];
189185

pnpm-lock.yaml

+13-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)