From ec8721b4f3d20f9d7caa8cd9b6091a7ddd0efbed Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Thu, 12 Sep 2024 19:54:54 -0700 Subject: [PATCH] chore: upgrade to chokidar 4 --- packages/language-server/package.json | 2 +- packages/svelte-check/package.json | 2 +- packages/svelte-check/src/index.ts | 13 +++++++++---- pnpm-lock.yaml | 22 ++++++++++++++++++---- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/packages/language-server/package.json b/packages/language-server/package.json index f3702c47b..e543b7013 100644 --- a/packages/language-server/package.json +++ b/packages/language-server/package.json @@ -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", diff --git a/packages/svelte-check/package.json b/packages/svelte-check/package.json index 634a029f6..5ab1bd504 100644 --- a/packages/svelte-check/package.json +++ b/packages/svelte-check/package.json @@ -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" diff --git a/packages/svelte-check/src/index.ts b/packages/svelte-check/src/index.ts index 866d23bf3..56f490258 100644 --- a/packages/svelte-check/src/index.ts +++ b/packages/svelte-check/src/index.ts @@ -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(); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f1bc6d8f0..2c78eb74e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -31,8 +31,8 @@ importers: specifier: 2.8.4 version: 2.8.4 chokidar: - specifier: ^3.4.1 - version: 3.5.3 + specifier: ^4.0.0 + version: 4.0.0 estree-walker: specifier: ^2.0.1 version: 2.0.2 @@ -113,8 +113,8 @@ importers: specifier: ^0.3.25 version: 0.3.25 chokidar: - specifier: ^3.4.1 - version: 3.5.3 + specifier: ^4.0.0 + version: 4.0.0 fdir: specifier: ^6.2.0 version: 6.2.0 @@ -620,6 +620,10 @@ packages: resolution: {integrity: sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==} engines: {node: '>= 8.10.0'} + chokidar@4.0.0: + resolution: {integrity: sha512-mxIojEAQcuEvT/lyXq+jf/3cO/KoA6z4CeNDGGevTybECPOMFCnQy3OPahluUkbqgPNGw5Bi78UC7Po6Lhy+NA==} + engines: {node: '>= 14.16.0'} + clean-stack@2.2.0: resolution: {integrity: sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==} engines: {node: '>=6'} @@ -1108,6 +1112,10 @@ packages: resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==} engines: {node: '>=8.10.0'} + readdirp@4.0.1: + resolution: {integrity: sha512-GkMg9uOTpIWWKbSsgwb5fA4EavTR+SG/PMPoAY8hkhHfEEY0/vqljY+XHqtDf2cr2IJtoNRDbrrEpZUiZCkYRw==} + engines: {node: '>= 14.16.0'} + require-directory@2.1.1: resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==} engines: {node: '>=0.10.0'} @@ -1684,6 +1692,10 @@ snapshots: optionalDependencies: fsevents: 2.3.3 + chokidar@4.0.0: + dependencies: + readdirp: 4.0.1 + clean-stack@2.2.0: {} cliui@7.0.4: @@ -2162,6 +2174,8 @@ snapshots: dependencies: picomatch: 2.3.1 + readdirp@4.0.1: {} + require-directory@2.1.1: {} resolve@1.22.2: