mirror of
https://github.com/denoland/deno.git
synced 2025-01-01 03:54:06 -05:00
parent
9533a030f3
commit
be9aaa664a
2 changed files with 12 additions and 1 deletions
|
@ -155,3 +155,14 @@ test(function booleanParsingFalse(): void {
|
||||||
|
|
||||||
assertEquals(parsed.boool, false);
|
assertEquals(parsed.boool, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test(function booleanParsingTrueLike(): void {
|
||||||
|
const parsed = parse(["-t", "true123"], { boolean: ["t"] });
|
||||||
|
assertEquals(parsed.t, true);
|
||||||
|
|
||||||
|
const parsed2 = parse(["-t", "123"], { boolean: ["t"] });
|
||||||
|
assertEquals(parsed2.t, true);
|
||||||
|
|
||||||
|
const parsed3 = parse(["-t", "false123"], { boolean: ["t"] });
|
||||||
|
assertEquals(parsed3.t, true);
|
||||||
|
});
|
||||||
|
|
|
@ -271,7 +271,7 @@ export function parse(
|
||||||
) {
|
) {
|
||||||
setArg(key, args[i + 1], arg);
|
setArg(key, args[i + 1], arg);
|
||||||
i++;
|
i++;
|
||||||
} else if (args[i + 1] && /true|false/.test(args[i + 1])) {
|
} else if (args[i + 1] && /^(true|false)$/.test(args[i + 1])) {
|
||||||
setArg(key, args[i + 1] === "true", arg);
|
setArg(key, args[i + 1] === "true", arg);
|
||||||
i++;
|
i++;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue