Skip to content

Commit 2e7146e

Browse files
theCodeDriftclaude
andcommitted
perf(cli): start the gitignore and converter scans together
`listGitIgnoredEntries` spawns git and `findConverterDependentFiles` walks the tree, and neither result feeds the other: the first shapes the `--glob` argument, the second shapes the skipped-files notice, and only the final filter combines them. Awaited in series they charged every whole-project Vale run a subprocess plus a directory walk back to back, ahead of the Vale spawn that had yet to start. `Promise.all` overlaps them; behavior is unchanged. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017cEN93Acyp4zBwP3oDnyy1
1 parent e7477f5 commit 2e7146e

1 file changed

Lines changed: 23 additions & 17 deletions

File tree

  • packages/cli/src/rules/vale

‎packages/cli/src/rules/vale/run.ts‎

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,29 @@ export async function runVale(
218218
// `.gitignore` already — which is precisely why the two engines disagreed
219219
// about which files the project contains. Asked only when we chose `.`
220220
// ourselves, so `check worktrees/probe` still checks what it was handed.
221-
const ignoredEntries = wholeProject
222-
? await listGitIgnoredEntries(options.cwd)
223-
: [];
221+
//
222+
// Started together with the converter-dependent scan below, because neither
223+
// answer feeds the other: the ignore list shapes the `--glob` argument, the
224+
// scan shapes the skipped-files notice, and only the `.filter` further down
225+
// ever brings the two together. Awaited in series they would charge every
226+
// whole-project run a git subprocess and then a directory walk, back to
227+
// back, before the Vale subprocess has even been spawned.
228+
//
229+
// The notice half of that pair is asked before the run rather than inferred
230+
// from it. Vale never reports what its walker declined to open, so once the
231+
// glob has done its job the skipped files are unrecoverable from the output,
232+
// and a fix whose only visible effect is that some findings are quietly
233+
// missing is the bug it replaced.
234+
//
235+
// The ignored paths are filtered back out for the same reason the notice
236+
// exists at all: it must describe the run that happened. An `.adoc` inside
237+
// `worktrees/` is not a file this run declined to convert, it is a file this
238+
// run was never going to look at, and naming it would send the reader to
239+
// investigate a directory the fix above deliberately excluded.
240+
const [ignoredEntries, converterDependent] = await Promise.all([
241+
wholeProject ? listGitIgnoredEntries(options.cwd) : [],
242+
findConverterDependentFiles(options.cwd, paths),
243+
]);
224244

225245
const exclude = [
226246
...(wholeProject
@@ -234,20 +254,6 @@ export async function runVale(
234254
const globArgument = buildValeGlob(exclude);
235255
const globFlags = globArgument === undefined ? [] : [globArgument];
236256

237-
// Asked before the run rather than inferred from it. Vale never reports what
238-
// its walker declined to open, so once the glob has done its job the skipped
239-
// files are unrecoverable from the output — and a fix whose only visible
240-
// effect is that some findings are quietly missing is the bug it replaced.
241-
//
242-
// The ignored paths are filtered back out for the same reason the notice
243-
// exists at all: it must describe the run that happened. An `.adoc` inside
244-
// `worktrees/` is not a file this run declined to convert — it is a file this
245-
// run was never going to look at, and naming it would send the reader to
246-
// investigate a directory the fix above deliberately excluded.
247-
const converterDependent = await findConverterDependentFiles(
248-
options.cwd,
249-
paths
250-
);
251257
const skipped = skippedFilesNotice(
252258
converterDependent.filter((file) => !isGitIgnoredPath(file, ignoredEntries))
253259
);

0 commit comments

Comments
 (0)