Fix config loading of boolean values

Setting values from config is a little tricky, but I think this makes it
work properly now.
This commit is contained in:
Wolvan 2021-12-29 17:04:23 +01:00
parent 16ca2ee8b1
commit 1507ea6d33
2 changed files with 6 additions and 5 deletions

6
.gitignore vendored
View file

@ -112,4 +112,8 @@ testing/
*.db
*.db3
# Data directory
data/
data/
# Config files
config*.js*
!config.example.json

View file

@ -58,10 +58,7 @@ async function loadConfig(options: CommanderOption[] = [], homedirConfigFilename
.version(version)
.option("-c, --config-path <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);