1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-28 01:59:06 -05:00
Original: 0b9e28f918
This commit is contained in:
迷渡 2019-09-04 22:06:29 +08:00 committed by Ryan Dahl
parent 9533a030f3
commit be9aaa664a
2 changed files with 12 additions and 1 deletions

View file

@ -155,3 +155,14 @@ test(function booleanParsingFalse(): void {
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);
});

View file

@ -271,7 +271,7 @@ export function parse(
) {
setArg(key, args[i + 1], arg);
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);
i++;
} else {