fix(scripts): reject short flag gauntlet values

This commit is contained in:
Vincent Koc
2026-06-21 21:18:48 +02:00
parent 52672c7af1
commit ebb670b208
2 changed files with 24 additions and 3 deletions

View File

@@ -82,7 +82,7 @@ export function parseArgs(argv) {
const arg = args[index];
const readValue = () => {
const value = args[index + 1];
if (!value || value.startsWith("--")) {
if (!value || value.startsWith("-")) {
throw new Error(`Missing value for ${arg}`);
}
index += 1;

View File

@@ -132,8 +132,29 @@ describe("plugin gateway gauntlet helpers", () => {
});
it("rejects valued flags followed by another option", () => {
for (const flag of ["--repo-root", "--output-dir", "--plugin", "--qa-scenario"]) {
expect(() => parseArgs([flag, "--skip-qa"])).toThrow(`Missing value for ${flag}`);
for (const flag of [
"--repo-root",
"--output-dir",
"--plugin",
"--shard-total",
"--shard-index",
"--limit",
"--qa-scenario",
"--qa-plugin-chunk-size",
"--cpu-core-warn",
"--hot-wall-warn-ms",
"--max-rss-warn-mb",
"--wall-anomaly-multiplier",
"--rss-anomaly-multiplier",
"--qa-cpu-regression-multiplier",
"--qa-wall-regression-multiplier",
"--command-timeout-ms",
"--build-timeout-ms",
"--qa-timeout-ms",
]) {
for (const value of ["--skip-qa", "-h"]) {
expect(() => parseArgs([flag, value])).toThrow(`Missing value for ${flag}`);
}
}
});