Skip to content

Commit

Permalink
chore: switch from fast-glob to fdir
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Jul 4, 2024
1 parent 00212c4 commit 34f0301
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 14 deletions.
2 changes: 1 addition & 1 deletion packages/svelte-check/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
20 changes: 15 additions & 5 deletions packages/svelte-check/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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) {
Expand Down
6 changes: 1 addition & 5 deletions packages/svelte-check/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -180,10 +180,6 @@ function getDiagnosticSources(opts: Record<string, any>): DiagnosticSource[] {
: diagnosticSources;
}

function getFilepathsToIgnore(opts: Record<string, any>): string[] {
return opts.ignore?.split(',') || [];
}

const thresholds = ['warning', 'error'] as const;
type Threshold = (typeof thresholds)[number];

Expand Down
16 changes: 13 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 34f0301

Please sign in to comment.