From e21164933a32118eb0d2d8cb4fc54db5783bbfc4 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 21 Jun 2026 21:36:26 +0200 Subject: [PATCH] fix(scripts): reject short flag report values --- scripts/lib/report-cli-helpers.mjs | 2 +- test/scripts/report-cli-helpers.test.ts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/lib/report-cli-helpers.mjs b/scripts/lib/report-cli-helpers.mjs index 46e4950af96..ac71227e4fd 100644 --- a/scripts/lib/report-cli-helpers.mjs +++ b/scripts/lib/report-cli-helpers.mjs @@ -7,7 +7,7 @@ import path from "node:path"; */ function readReportOptionValue(argv, index, optionName) { const value = argv[index + 1]; - if (value === undefined || value === "" || value.startsWith("--")) { + if (value === undefined || value === "" || value.startsWith("-")) { throw new Error(`Expected ${optionName} .`); } return value; diff --git a/test/scripts/report-cli-helpers.test.ts b/test/scripts/report-cli-helpers.test.ts index b8949be796c..ab72ad51f55 100644 --- a/test/scripts/report-cli-helpers.test.ts +++ b/test/scripts/report-cli-helpers.test.ts @@ -23,10 +23,15 @@ describe("report-cli-helpers", () => { expect(() => parseReportCliArgs(["--root", "--json", "report.json"])).toThrow( "Expected --root .", ); + expect(() => parseReportCliArgs(["--root", "-h"])).toThrow("Expected --root ."); expect(() => parseReportCliArgs(["--json"])).toThrow("Expected --json ."); expect(() => parseReportCliArgs(["--json", "--markdown", "report.md"])).toThrow( "Expected --json .", ); + expect(() => parseReportCliArgs(["--json", "-h"])).toThrow("Expected --json ."); expect(() => parseReportCliArgs(["--markdown", ""])).toThrow("Expected --markdown ."); + expect(() => parseReportCliArgs(["--markdown", "-h"])).toThrow( + "Expected --markdown .", + ); }); });