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

4
.gitignore vendored
View file

@ -113,3 +113,7 @@ testing/
*.db3 *.db3
# Data directory # 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) .version(version)
.option("-c, --config-path <path>", "Path to the configuration file to load", "./config"); .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)); options.forEach(([name, description, handler, defaultValue]) => program.option(name, description, handler, defaultValue));
Object.keys(config).forEach(option => program.setOptionValueWithSource(option, config[option], "config"));
Object.keys(program.opts()).forEach(option => {
if (config[option]) program.opts()[option] = config[option];
});
program.parse(process.argv); program.parse(process.argv);