Skip to content

Commit

Permalink
fix(cli): fix setting flag to false
Browse files Browse the repository at this point in the history
- This fixes `webdriver-manager update --gecko=false`
- This does not fix `webdriver-manager update --gecko=0`. Minimist interprets 0 as true.

closes #110
  • Loading branch information
cnishina committed Nov 8, 2016
1 parent f536a76 commit f289d44
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
25 changes: 18 additions & 7 deletions lib/cli/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,33 @@ export class Option {

getNumber(): number {
let value = this.getValue_();
if (value && typeof value === 'number') {
return +value;
if (value) {
return +this.getValue_();
} else {
return null;
}
return null;
}

getString(): string {
let value = this.getValue_();
if (value && typeof value === 'string') {
return '' + value;
if (value != null) {
return '' + this.getValue_();
} else {
return '';
}
return '';
}

getBoolean(): boolean {
let value = this.getValue_();
return Boolean(value);
if (value != null) {
if (typeof value === 'string') {
return !Boolean(value === '0' || value === 'false');
} else if (typeof value === 'number') {
return Boolean(value !== 0);
} else {
return value;
}
}
return false;
}
}
2 changes: 1 addition & 1 deletion lib/cli/programs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class Program {
let tempJson: any = json;
while (keyList.length > 0) {
let keyItem = keyList[0];
if (tempJson[keyItem]) {
if (tempJson[keyItem] != null) {
tempJson = tempJson[keyItem];
keyList = keyList.slice(1);
} else {
Expand Down

0 comments on commit f289d44

Please sign in to comment.