Skip to content

Commit 4486b7e

Browse files
committed
fix(cli): preserve equals in root option values
1 parent ff871e1 commit 4486b7e

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

src/cli/root-option-value.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { describe, expect, it } from "vitest";
2+
import { takeCliRootOptionValue } from "./root-option-value.js";
3+
4+
describe("takeCliRootOptionValue", () => {
5+
it("preserves equals signs after the first separator", () => {
6+
expect(takeCliRootOptionValue("--token=abc=def", undefined)).toEqual({
7+
value: "abc=def",
8+
consumedNext: false,
9+
});
10+
expect(takeCliRootOptionValue("--token=abc==", undefined)).toEqual({
11+
value: "abc==",
12+
consumedNext: false,
13+
});
14+
});
15+
16+
it("treats empty inline values as missing", () => {
17+
expect(takeCliRootOptionValue("--token=", "fallback")).toEqual({
18+
value: null,
19+
consumedNext: false,
20+
});
21+
});
22+
23+
it("continues to consume the next token for space-separated values", () => {
24+
expect(takeCliRootOptionValue("--token", "abc=def")).toEqual({
25+
value: "abc=def",
26+
consumedNext: true,
27+
});
28+
});
29+
});

src/cli/root-option-value.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export function takeCliRootOptionValue(
88
consumedNext: boolean;
99
} {
1010
if (raw.includes("=")) {
11-
const [, value] = raw.split("=", 2);
11+
const value = raw.slice(raw.indexOf("=") + 1);
1212
const trimmed = (value ?? "").trim();
1313
return { value: trimmed || null, consumedNext: false };
1414
}

0 commit comments

Comments
 (0)