Tidy up config, fix a couple minor bugs

This commit is contained in:
Bryan Ashby 2020-06-11 22:40:20 -06:00
parent 920684852c
commit fb9d83ab6f
No known key found for this signature in database
GPG Key ID: B49EB437951D2542
1 changed files with 15 additions and 18 deletions

View File

@ -1,6 +1,7 @@
// deps
const paths = require('path');
const async = require('async');
const moment = require('moment');
const _ = require('lodash');
const mapValuesDeep = require('deepdash/getMapValuesDeep')(_);
@ -55,7 +56,7 @@ module.exports = class ConfigLoader {
config,
(defaultVal, configVal, key, target, source) => {
var path;
while (true) {
while (true) { // eslint-disable-line no-constant-condition
if (!stack.length) {
stack.push({source, path : []});
}
@ -118,7 +119,9 @@ module.exports = class ConfigLoader {
case 'object' :
try {
value = JSON.parse(value);
} catch(e) { }
} catch(e) {
// ignored
}
break;
case 'date' :
@ -142,7 +145,7 @@ module.exports = class ConfigLoader {
}
_resolveEnvironmentVariable(spec) {
const [prefix, varName, type, array] = spec.split(':');
const [, varName, type, array] = spec.split(':');
if (!varName) {
return;
}
@ -175,13 +178,8 @@ module.exports = class ConfigLoader {
});
}
_configFileChanged({fileName, fileRoot, configCache}) {
_configFileChanged({fileName, fileRoot}) {
const reCachedPath = paths.join(fileRoot, fileName);
configCache.getConfig(reCachedPath, (err, config) => {
if (err) {
return console.stdout(`Configuration ${reCachedPath} is invalid: ${err.message}`); // eslint-disable-line no-console
}
if (this.configPaths.includes(reCachedPath)) {
this._reload(this.baseConfigPath, err => {
if (!err) {
@ -190,7 +188,6 @@ module.exports = class ConfigLoader {
}
});
}
});
}
_resolveIncludes(configRoot, config, cb) {