diff --git a/scripts/test-env-mutation-report.ts b/scripts/test-env-mutation-report.ts index 9a80ec709e0c..1dcfc56f73d0 100644 --- a/scripts/test-env-mutation-report.ts +++ b/scripts/test-env-mutation-report.ts @@ -403,7 +403,7 @@ function parseArgs(argv: string[]): { } if (arg === "--repo-root") { const value = argv[index + 1]; - if (!value || value.startsWith("--")) { + if (!value || value.startsWith("-")) { throw new Error("--repo-root expects a path"); } repoRoot = value; diff --git a/test/scripts/test-env-mutation-report.test.ts b/test/scripts/test-env-mutation-report.test.ts index 6da083a72e78..9b0ad5307e61 100644 --- a/test/scripts/test-env-mutation-report.test.ts +++ b/test/scripts/test-env-mutation-report.test.ts @@ -163,24 +163,26 @@ describe("collectTestEnvMutationReport", () => { expect(result.stderr).toBe(""); }); - it("rejects missing CLI repo roots instead of scanning zero files", () => { - const result = spawnSync( - process.execPath, - [ - "--import", - "tsx", - path.join(process.cwd(), "scripts/test-env-mutation-report.ts"), - "--", - "--repo-root", - "--json", - ], - { - encoding: "utf8", - }, - ); + it("rejects missing or flag-shaped CLI repo roots instead of scanning zero files", () => { + for (const value of ["--json", "-h"]) { + const result = spawnSync( + process.execPath, + [ + "--import", + "tsx", + path.join(process.cwd(), "scripts/test-env-mutation-report.ts"), + "--", + "--repo-root", + value, + ], + { + encoding: "utf8", + }, + ); - expect(result.status).toBe(1); - expect(result.stderr).toContain("--repo-root expects a path"); + expect(result.status).toBe(1); + expect(result.stderr).toContain("--repo-root expects a path"); + } }); it("rejects loose CLI limits before scanning the repository", () => {