Handle boolean values in config.ini properly

master
Dragory 2019-12-03 03:00:26 +02:00
parent 0a4d97fc11
commit 7e567a3267
1 changed files with 10 additions and 0 deletions

View File

@ -273,6 +273,16 @@ for (const numericOpt of numericOptions) {
} }
} }
// Cast boolean options (on, true, 1) (off, false, 0)
for (const [key, value] of Object.entries(finalConfig)) {
if (typeof value !== "string") continue;
if (["on", "true", "1"].includes(value)) {
finalConfig[key] = true;
} else if (["off", "false", "0"].includes(value)) {
finalConfig[key] = false;
}
}
// Make sure all of the required config options are present // Make sure all of the required config options are present
for (const opt of required) { for (const opt of required) {
if (! finalConfig[opt]) { if (! finalConfig[opt]) {