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
This commit is contained in:
1 parent
008fbdd587
commit
16d3376410
2 files changed
+7
-1
No files matched your search
@@ -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;
|
||||
|
||||
@@ -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", () => {
|
||||
|
||||
Reference in new issue
Block a user