fix(critique-storage): make CLI entry-point check Windows-safe (#155)

The `import.meta.url === \`file://\${process.argv[1]}\`` guard at the
bottom of critique-storage.mjs silently failed on Windows: Node sets
import.meta.url to file:///D:/... (forward slashes) but process.argv[1]
is D:\... (backslashes), so the string compare returns false, main()
never runs, and the script exits 0 with no output. The OpenCode reporter
saw "/impeccable critique" skip the snapshot save with no error.

Switch to pathToFileURL(process.argv[1]).href, the standard cross-
platform pattern already used everywhere else in the repo.

Adds three CLI subprocess tests so future regressions of this guard
are caught even on macOS/Linux CI.

Fixes #155.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Paul Bakaus
2026-05-14 15:48:27 -07:00
co-authored by Claude Opus 4.7
parent e493504496
commit 5f15163c2b
15 changed files with 119 additions and 15 deletions
+6 -1
View File
@@ -27,6 +27,7 @@
import fs from 'node:fs';
import path from 'node:path';
import { pathToFileURL } from 'node:url';
import { getCritiqueDir } from './impeccable-paths.mjs';
const SLUG_MAX = 50;
@@ -221,6 +222,10 @@ function main(argv) {
}
}
if (import.meta.url === `file://${process.argv[1]}`) {
// Why pathToFileURL: on Windows, import.meta.url is file:///D:/... (forward
// slashes) while process.argv[1] is D:\... (backslashes), so the naive
// `file://${process.argv[1]}` compare fails and main() never runs — the
// script silently exits 0. pathToFileURL normalizes both. (issue #155)
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
main(process.argv.slice(2));
}