From 1b17517969251e7fe4a9c236d888121bb52112cd Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 21 Jun 2026 21:32:07 +0200 Subject: [PATCH] fix(scripts): reject short flag closeout values --- scripts/verify-stable-main-closeout.mjs | 2 +- .../verify-stable-main-closeout.test.ts | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 test/scripts/verify-stable-main-closeout.test.ts diff --git a/scripts/verify-stable-main-closeout.mjs b/scripts/verify-stable-main-closeout.mjs index 03069921152..f0b9cf6e0df 100644 --- a/scripts/verify-stable-main-closeout.mjs +++ b/scripts/verify-stable-main-closeout.mjs @@ -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); diff --git a/test/scripts/verify-stable-main-closeout.test.ts b/test/scripts/verify-stable-main-closeout.test.ts new file mode 100644 index 00000000000..c8dbf49ac7d --- /dev/null +++ b/test/scripts/verify-stable-main-closeout.test.ts @@ -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."); + }); +});