feat(config): add option to specify default value to env var expansion (#5020)
* feat: Add option to specify default value to env var expansion * fix: remove unused capturing group for env var replacement Co-authored-by: Nicolas Giard <github@ngpixel.com>
This commit is contained in:
parent
2815f38c52
commit
de6d4beef9
@ -15,6 +15,6 @@ ssl:
|
|||||||
provider: letsencrypt
|
provider: letsencrypt
|
||||||
domain: $(LETSENCRYPT_DOMAIN)
|
domain: $(LETSENCRYPT_DOMAIN)
|
||||||
subscriberEmail: $(LETSENCRYPT_EMAIL)
|
subscriberEmail: $(LETSENCRYPT_EMAIL)
|
||||||
logLevel: info
|
logLevel: $(LOG_LEVEL:info)
|
||||||
logFormat: $(LOG_FORMAT)
|
logFormat: $(LOG_FORMAT:default)
|
||||||
ha: $(HA_ACTIVE)
|
ha: $(HA_ACTIVE)
|
||||||
|
@ -8,14 +8,18 @@ module.exports = {
|
|||||||
/**
|
/**
|
||||||
* Parse configuration value for environment vars
|
* Parse configuration value for environment vars
|
||||||
*
|
*
|
||||||
|
* Replaces `$(ENV_VAR_NAME)` with value of `ENV_VAR_NAME` environment variable.
|
||||||
|
*
|
||||||
|
* Also supports defaults by if provided as `$(ENV_VAR_NAME:default)`
|
||||||
|
*
|
||||||
* @param {any} cfg Configuration value
|
* @param {any} cfg Configuration value
|
||||||
* @returns Parse configuration value
|
* @returns Parse configuration value
|
||||||
*/
|
*/
|
||||||
parseConfigValue (cfg) {
|
parseConfigValue (cfg) {
|
||||||
return _.replace(
|
return _.replace(
|
||||||
cfg,
|
cfg,
|
||||||
/\$\(([A-Z0-9_]+)\)/g,
|
/\$\(([A-Z0-9_]+)(?::(.+))?\)/g,
|
||||||
(fm, m) => { return process.env[m] }
|
(fm, m, d) => { return process.env[m] || d }
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user