From 46b5287a2c13b177441197fdc4f0838415c9f6ae Mon Sep 17 00:00:00 2001 From: Drew Short Date: Tue, 7 Jan 2020 13:41:48 -0600 Subject: [PATCH] Added a flag to force re-reading configs --- bot/config.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bot/config.js b/bot/config.js index 9c1a7a7..84acfb0 100644 --- a/bot/config.js +++ b/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); } }