GeezerVison is showing github.com — Reject flag tokens as values in dev-runner arg parsing · atscub/t3code@c9a59a2
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: scripts/dev-runner.mjs +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -131,7 +131,7 @@ export function parseDevRunnerArgs(rawArgs) { |
131 | 131 | let value = parsedFlag.value; |
132 | 132 | if (value === undefined) { |
133 | 133 | const next = args[index + 1]; |
134 | | - if (next === undefined) { |
| 134 | + if (next === undefined || next === "--" || next.startsWith("-")) { |
135 | 135 | throw new Error(`Missing value for --${parsedFlag.name}`); |
136 | 136 | } |
137 | 137 | value = next; |
|
Collapse file
Copy file name to clipboardExpand all lines: scripts/dev-runner.test.ts +6Lines changed: 6 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -30,6 +30,12 @@ describe("parseDevRunnerArgs", () => { |
30 | 30 | it("throws when a value flag is missing its value", () => { |
31 | 31 | expect(() => parseDevRunnerArgs(["--state-dir"])).toThrow("Missing value for --state-dir"); |
32 | 32 | }); |
| 33 | + |
| 34 | + it("throws when a value flag is followed by another flag token", () => { |
| 35 | + expect(() => parseDevRunnerArgs(["--state-dir", "--continue"])).toThrow( |
| 36 | + "Missing value for --state-dir", |
| 37 | + ); |
| 38 | + }); |
33 | 39 | }); |
34 | 40 |
|
35 | 41 | describe("createDevRunnerEnv", () => { |
|