From c9a59a26bb85902b9b2e828e1f99cc0760105ae4 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Thu, 26 Feb 2026 18:21:38 -0800 Subject: [PATCH] Reject flag tokens as values in dev-runner arg parsing - Treat `--` and `-...` tokens after value flags as missing values - Add regression test for `--state-dir --continue` to throw the expected error --- scripts/dev-runner.mjs | 2 +- scripts/dev-runner.test.ts | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/dev-runner.mjs b/scripts/dev-runner.mjs index 67ffbc2b6937f2e14238bda30a7bf57195592e1a..1c6efcc63d6068221babce6b0509274c7f715a82 100644 --- a/scripts/dev-runner.mjs +++ b/scripts/dev-runner.mjs @@ -131,7 +131,7 @@ export function parseDevRunnerArgs(rawArgs) { let value = parsedFlag.value; if (value === undefined) { const next = args[index + 1]; - if (next === undefined) { + if (next === undefined || next === "--" || next.startsWith("-")) { throw new Error(`Missing value for --${parsedFlag.name}`); } value = next; diff --git a/scripts/dev-runner.test.ts b/scripts/dev-runner.test.ts index 98dd5bd53be814263870692c7a241bf2378757f0..4501bf7922705fdcc736004848020c1922fb4801 100644 --- a/scripts/dev-runner.test.ts +++ b/scripts/dev-runner.test.ts @@ -30,6 +30,12 @@ describe("parseDevRunnerArgs", () => { it("throws when a value flag is missing its value", () => { expect(() => parseDevRunnerArgs(["--state-dir"])).toThrow("Missing value for --state-dir"); }); + + it("throws when a value flag is followed by another flag token", () => { + expect(() => parseDevRunnerArgs(["--state-dir", "--continue"])).toThrow( + "Missing value for --state-dir", + ); + }); }); describe("createDevRunnerEnv", () => { -- 2.54.0