Skip to content

Commit

Permalink
chore: upgrade to chokidar 4
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Sep 13, 2024
1 parent 0921d65 commit ec8721b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/language-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"dependencies": {
"@jridgewell/trace-mapping": "^0.3.25",
"@vscode/emmet-helper": "2.8.4",
"chokidar": "^3.4.1",
"chokidar": "^4.0.0",
"estree-walker": "^2.0.1",
"fdir": "^6.2.0",
"lodash": "^4.17.21",
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte-check/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"dependencies": {
"@jridgewell/trace-mapping": "^0.3.25",
"chokidar": "^3.4.1",
"chokidar": "^4.0.0",
"fdir": "^6.2.0",
"picocolors": "^1.0.0",
"sade": "^1.7.4"
Expand Down
13 changes: 9 additions & 4 deletions packages/svelte-check/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,20 @@ class DiagnosticsWatcher {
filePathsToIgnore: string[],
ignoreInitialAdd: boolean
) {
watch(`${workspaceUri.fsPath}/**/*.{svelte,d.ts,ts,js,jsx,tsx,mjs,cjs,mts,cts}`, {
const ifMatching = (path: string, f: Function) => {
if (/\.(svelte|d\.ts|ts|js|jsx|tsx|mjs|cjs|mts|cts)$/.test(path)) {
f();
}
}
watch(workspaceUri.fsPath, {
ignored: ['node_modules', 'vite.config.{js,ts}.timestamp-*']
.concat(filePathsToIgnore)
.map((ignore) => path.join(workspaceUri.fsPath, ignore)),
ignoreInitial: ignoreInitialAdd
})
.on('add', (path) => this.updateDocument(path, true))
.on('unlink', (path) => this.removeDocument(path))
.on('change', (path) => this.updateDocument(path, false));
.on('add', (path) => ifMatching(path, () => this.updateDocument(path, true)))
.on('unlink', (path) => ifMatching(path, () => this.removeDocument(path)))
.on('change', (path) => ifMatching(path, () => this.updateDocument(path, false)));

if (ignoreInitialAdd) {
this.scheduleDiagnostics();
Expand Down
22 changes: 18 additions & 4 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 ec8721b

Please sign in to comment.