Skip to content

Commit 1227939

Browse files
mark-wiemerCopilot
andauthored
fix: support --X one-char aliases (#6391)
Co-authored-by: Copilot App <[email protected]>
1 parent bb2e69a commit 1227939

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎lib/cli/parse-args.js‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,11 @@ const preprocessArgs = (allArgs) => {
174174
const negated = name.startsWith("no-");
175175
const prefix = arg.startsWith("--") ? "--" : arg.startsWith("-") ? "-" : "";
176176

177-
if (!prefix || name === canonical || name.length === 1) {
177+
if (
178+
!prefix ||
179+
name === canonical ||
180+
(prefix === "-" && name.length === 1)
181+
) {
178182
return arg;
179183
}
180184

‎test/node-unit/cli/parse-args.spec.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ describe("parse-args", function () {
4242
});
4343
});
4444

45+
it("canonicalizes single-character aliases with a long-option prefix", function () {
46+
[["--t", "0"], ["--t=0"]].forEach((args) => {
47+
expect(parseMochaArgs(args, defaults), "to satisfy", {
48+
_: [],
49+
timeout: "0",
50+
});
51+
});
52+
});
53+
4554
it("uses the last value for repeated scalar options across aliases", function () {
4655
expect(
4756
parseMochaArgs(["--timeout", "100", "-t", "10"], defaults),

0 commit comments

Comments
 (0)