Browse Source

Added a flag to force re-reading configs

develop
Drew Short 5 years ago
parent
commit
46b5287a2c
  1. 8
      bot/config.js

8
bot/config.js

@ -11,8 +11,10 @@ function sanitizeConfig(config, fields=[]) {
return clonedConfig;
}
function getConfig(configFile, sanitizedFields=[]) {
if (!loadedConfigs.has(configFile)) {
function getConfig(configFile, sanitizedFields=[], reload=false) {
if (loadedConfigs.has(configFile) && !reload) {
return loadedConfigs.get(configFile);
} else {
logger.info("Reading config: %s", configFile);
let rawConfigData = fs.readFileSync(configFile);
let config = JSON.parse(rawConfigData);
@ -20,8 +22,6 @@ function getConfig(configFile, sanitizedFields=[]) {
logger.debug("%o", sanitizeConfig(config, sanitizedFields));
loadedConfigs.set(configFile, config);
return config;
} else {
return loadedConfigs.get(configFile);
}
}
Loading…
Cancel
Save