Fix #10967, allow boolean flags to have explicit value (#11798)

* Fix #10967, allow boolean flag to have explicit value

* add commandLineParsing test for boolean flags
This commit is contained in:
(´・ω・`)
2016-10-25 01:45:07 +08:00
committed by Mohamed Hegazy
parent e38c004f90
commit 287b54518d
2 changed files with 41 additions and 2 deletions

View File

@@ -599,7 +599,13 @@ namespace ts {
i++;
break;
case "boolean":
options[opt.name] = true;
// boolean flag has optional value true, false, others
let optValue = args[i];
options[opt.name] = optValue !== "false";
// consume next argument as boolean flag value
if (optValue === "false" || optValue === "true") {
i++;
}
break;
case "string":
options[opt.name] = args[i] || "";