From f353ecbd9e9e8e409303bb4f5c5590e95f579869 Mon Sep 17 00:00:00 2001 From: marzavec Date: Sun, 7 Apr 2019 17:04:10 -0700 Subject: refactoring 2 of 2 --- server/src/serverLib/ConfigManager.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'server/src/serverLib/ConfigManager.js') diff --git a/server/src/serverLib/ConfigManager.js b/server/src/serverLib/ConfigManager.js index ebec050..36af1ec 100644 --- a/server/src/serverLib/ConfigManager.js +++ b/server/src/serverLib/ConfigManager.js @@ -15,10 +15,10 @@ class ConfigManager { /** * Create a `ConfigManager` instance for managing application settings * - * @param {String} base executing directory name; __dirname + * @param {String} basePath executing directory name; __dirname */ - constructor (base = __dirname) { - this.configPath = path.resolve(base, 'config/config.json'); + constructor (basePath = __dirname) { + this.configPath = path.resolve(basePath, 'config/config.json'); if (!fse.existsSync(this.configPath)){ fse.ensureFileSync(this.configPath); @@ -26,10 +26,9 @@ class ConfigManager { } /** - * (Re)builds the config.json (main server config), or loads the config into mem - * if rebuilding, process will exit- this is to allow a process manager to take over + * Loads config.json (main server config) into mem * - * @param {Boolean} reconfiguring set to true by `scripts/configure.js`, will exit if true + * @return {Object || Boolean} False if the config.json could not be loaded */ async load () { try { @@ -44,6 +43,7 @@ class ConfigManager { /** * Creates backup of current config into configPath * + * @return {String} Backed up config.json path */ async backup () { const backupPath = `${this.configPath}.${dateFormat('dd-mm-yy-HH-MM-ss')}.bak`; @@ -56,6 +56,7 @@ class ConfigManager { * First makes a backup of the current `config.json`, then writes current config * to disk * + * @return {Boolean} False on failure */ async save () { const backupPath = await this.backup(); @@ -77,6 +78,8 @@ class ConfigManager { * * @param {*} key arbitrary configuration key * @param {*} value new value to change `key` to + * + * @return {Boolean} False on failure */ async set (key, value) { const realKey = `${key}`; -- cgit v1.2.1