fix(scripts): reject short flag closeout values

This commit is contained in:
Vincent Koc 2026-06-21 21:32:07 +02:00
parent 86fea26797
commit 1b17517969
No known key found for this signature in database
2 changed files with 22 additions and 1 deletions

View file

@ -13,7 +13,7 @@ function parseArgs(argv) {
throw new Error(`unexpected argument: ${key}`);
}
const value = argv[index + 1];
if (!value || value.startsWith("--")) {
if (!value || value.startsWith("-")) {
throw new Error(`${key} requires a value.`);
}
values.set(key.slice(2), value);

View file

@ -0,0 +1,21 @@
// Verify Stable Main Closeout tests cover stable closeout CLI behavior.
import { spawnSync } from "node:child_process";
import path from "node:path";
import { describe, expect, it } from "vitest";
function runCli(...args: string[]) {
return spawnSync(process.execPath, ["scripts/verify-stable-main-closeout.mjs", ...args], {
cwd: path.resolve("."),
encoding: "utf8",
});
}
describe("verify-stable-main-closeout", () => {
it("rejects option-shaped values before checking required arguments", () => {
const result = runCli("--tag", "-h");
expect(result.status).toBe(1);
expect(result.stdout).toBe("");
expect(result.stderr.trim()).toBe("--tag requires a value.");
});
});