deal with (possible, future) non-alnum config keys
This commit is contained in:
parent
25e6409cc9
commit
435cab01c8
|
@ -367,9 +367,13 @@ function applyEnvOverrides(config: Source) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _step2name(step: string|number): string {
|
||||||
|
return step.toString().replaceAll(/[^a-z0-9]+/gi,'').toUpperCase();
|
||||||
|
}
|
||||||
|
|
||||||
// this recurses down, bailing out if there's no config to override
|
// this recurses down, bailing out if there's no config to override
|
||||||
function _descend(thisConfig: any, name: string, thisStep: string | number, steps: (string | number)[]) {
|
function _descend(thisConfig: any, name: string, thisStep: string | number, steps: (string | number)[]) {
|
||||||
name = `${name}${thisStep.toString().toUpperCase()}_`;
|
name = `${name}${_step2name(thisStep)}_`;
|
||||||
thisConfig = thisConfig[thisStep];
|
thisConfig = thisConfig[thisStep];
|
||||||
if (!thisConfig) return;
|
if (!thisConfig) return;
|
||||||
_apply_inner(thisConfig, name, steps);
|
_apply_inner(thisConfig, name, steps);
|
||||||
|
@ -378,7 +382,7 @@ function applyEnvOverrides(config: Source) {
|
||||||
// this is the bottom of the recursion: look at the environment and
|
// this is the bottom of the recursion: look at the environment and
|
||||||
// set the value
|
// set the value
|
||||||
function _lastBit(thisConfig: any, name: string, lastStep: string | number) {
|
function _lastBit(thisConfig: any, name: string, lastStep: string | number) {
|
||||||
name = `${name}${lastStep.toString().toUpperCase()}`;
|
name = `${name}${_step2name(lastStep)}`;
|
||||||
|
|
||||||
const val = process.env[`MK_CONFIG_${name}`];
|
const val = process.env[`MK_CONFIG_${name}`];
|
||||||
if (val != null && val != undefined) {
|
if (val != null && val != undefined) {
|
||||||
|
|
Loading…
Reference in New Issue