From 1507ea6d337831ed628d2d5352a2407856fc7c39 Mon Sep 17 00:00:00 2001 From: Wolvan Date: Wed, 29 Dec 2021 17:04:23 +0100 Subject: [PATCH] Fix config loading of boolean values Setting values from config is a little tricky, but I think this makes it work properly now. --- .gitignore | 6 +++++- src/config-loader.ts | 5 +---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 316a8ed..add605b 100644 --- a/.gitignore +++ b/.gitignore @@ -112,4 +112,8 @@ testing/ *.db *.db3 # Data directory -data/ \ No newline at end of file +data/ + +# Config files +config*.js* +!config.example.json diff --git a/src/config-loader.ts b/src/config-loader.ts index 4896b5e..f250ebe 100644 --- a/src/config-loader.ts +++ b/src/config-loader.ts @@ -58,10 +58,7 @@ async function loadConfig(options: CommanderOption[] = [], homedirConfigFilename .version(version) .option("-c, --config-path ", "Path to the configuration file to load", "./config"); options.forEach(([name, description, handler, defaultValue]) => program.option(name, description, handler, defaultValue)); - - Object.keys(program.opts()).forEach(option => { - if (config[option]) program.opts()[option] = config[option]; - }); + Object.keys(config).forEach(option => program.setOptionValueWithSource(option, config[option], "config")); program.parse(process.argv);