recognise numbers and boolean values

This commit is contained in:
dakkar 2024-03-24 11:17:55 +00:00
parent 0e8cdb30b7
commit 4271402e0d
1 changed files with 10 additions and 0 deletions

View File

@ -390,6 +390,8 @@ function applyEnvOverrides(config: Source) {
} }
} }
const alwaysStrings = { 'chmodSocket': 1 };
function _assign(path: (string | number)[], lastStep: string | number, value: string) { function _assign(path: (string | number)[], lastStep: string | number, value: string) {
let thisConfig = config; let thisConfig = config;
for (const step of path) { for (const step of path) {
@ -399,6 +401,14 @@ function applyEnvOverrides(config: Source) {
thisConfig = thisConfig[step]; thisConfig = thisConfig[step];
} }
if (!alwaysStrings[lastStep]) {
if (value.match(/^[0-9]+$/)) {
value = parseInt(value);
} else if (value.match(/^(true|false)$/i)) {
value = !!value.match(/^true$/i);
}
}
thisConfig[lastStep] = value; thisConfig[lastStep] = value;
} }