Skip to content

Commit 63ccedb

Browse files
committed
🤖 fix: validate --mux-root values
1 parent 2edd9d8 commit 63ccedb

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/cli/argv.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,15 @@ describe("consumeMuxRootFromArgv", () => {
136136
expect(result.error).toBe("Missing value for --mux-root");
137137
expect(argv).toEqual(["bun", "script.ts", "--mux-root"]);
138138
});
139+
140+
test("returns error when flag value is another flag", () => {
141+
const env = detectCliEnvironment({}, undefined);
142+
const argv = ["bun", "script.ts", "--mux-root", "--help", "server"];
143+
const result = consumeMuxRootFromArgv(argv, env);
144+
145+
expect(result.error).toBe("Missing value for --mux-root");
146+
expect(argv).toEqual(["bun", "script.ts", "--mux-root", "--help", "server"]);
147+
});
139148
});
140149

141150
describe("getArgsAfterSplice", () => {

src/cli/argv.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export function consumeMuxRootFromArgv(
7373

7474
if (arg === "--mux-root" || arg === "--root") {
7575
const value = argv[i + 1];
76-
if (value === undefined) {
76+
if (value === undefined || value.startsWith("-")) {
7777
return { error: `Missing value for ${arg}` };
7878
}
7979

0 commit comments

Comments
 (0)