Skip to content

Commit 41c252a

Browse files
committed
fix: address greptile P2 review comments
- Cache defaultCodeExtensions at module level in isCodeFile so callers that pass no pre-built set avoid a per-call Set allocation - Add motivation comment to scripts/run-vitest.mjs explaining why the wrapper exists instead of invoking vitest directly - Always assign runtimeOverrides in applyServerConfig even when empty, so stale overrides don't persist if config hints are later removed
1 parent 6298016 commit 41c252a

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

scripts/run-vitest.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Spawns vitest via process.execPath to avoid bin-resolution failures when
2+
// Node is invoked directly (e.g. `node scripts/run-vitest.mjs`) without pnpm.
13
import { spawn } from 'node:child_process';
24
import { fileURLToPath } from 'node:url';
35

src/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1667,10 +1667,8 @@ async function applyServerConfig(
16671667
configRoots.set(rootKey, { rootPath: proj.root });
16681668
registerKnownRoot(proj.root);
16691669
const runtimeOverrides = buildProjectRuntimeOverrides(proj);
1670-
if (Object.keys(runtimeOverrides).length > 0) {
1671-
const project = getOrCreateProject(proj.root);
1672-
project.runtimeOverrides = runtimeOverrides;
1673-
}
1670+
const project = getOrCreateProject(proj.root);
1671+
project.runtimeOverrides = runtimeOverrides;
16741672
} catch {
16751673
console.error(`[config] Skipping inaccessible project root: ${proj.root}`);
16761674
}

src/utils/language-detection.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ function buildCodeExtensions(extraExtensions?: Iterable<string>): Set<string> {
176176
return merged;
177177
}
178178

179+
// Cached default set — built once at module load, reused by callers that pass no extra extensions.
180+
const defaultCodeExtensions: ReadonlySet<string> = buildCodeExtensions();
181+
179182
/**
180183
* Detect language from file path
181184
*/
@@ -193,7 +196,11 @@ export function isCodeFile(
193196
): boolean {
194197
const ext = path.extname(filePath).toLowerCase();
195198
const supportedExtensions =
196-
extensions instanceof Set ? extensions : buildCodeExtensions(extensions);
199+
extensions instanceof Set
200+
? extensions
201+
: extensions
202+
? buildCodeExtensions(extensions)
203+
: defaultCodeExtensions;
197204
return supportedExtensions.has(ext);
198205
}
199206

0 commit comments

Comments
 (0)