mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-22 17:43:09 +02:00
deal with (possible, future) non-alnum config keys
This commit is contained in:
parent
25e6409cc9
commit
435cab01c8
1 changed files with 6 additions and 2 deletions
|
@ -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 a new issue