From 229b916cd5b85fd9ba8ff94335e437dcb3859743 Mon Sep 17 00:00:00 2001 From: Timo Hocker Date: Fri, 5 Jun 2020 13:22:54 +0200 Subject: [PATCH] fix boolean defaults --- lib/InteractiveOptions.ts | 8 ++++++-- lib/Sources/ArgSource.ts | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/InteractiveOptions.ts b/lib/InteractiveOptions.ts index 1cca9a0..789af42 100644 --- a/lib/InteractiveOptions.ts +++ b/lib/InteractiveOptions.ts @@ -96,9 +96,13 @@ export class InteractiveOptions extends Persistent { // eslint-disable-next-line no-await-in-loop await src.parse (this.options); } - for (const opt of this.options) + for (const opt of this.options) { + if (!opt.filled) { + opt.value = opt.default; + opt.filled = true; + } this.set (opt.name, opt.value); - + } return this.to_object (); } } diff --git a/lib/Sources/ArgSource.ts b/lib/Sources/ArgSource.ts index e5ebc27..74efc64 100644 --- a/lib/Sources/ArgSource.ts +++ b/lib/Sources/ArgSource.ts @@ -28,10 +28,12 @@ export class ArgSource extends OptionSource { } }; for (const opt of options) { + const type = opt.type_validation.persistent_type; yargs_config[opt.name] = { alias: opt.alias, - default: opt.default, - type: opt.type_validation.persistent_type, + // eslint-disable-next-line no-undefined + default: type === 'boolean' ? undefined : opt.default, + type, describe: opt.description }; }