From 0a75eb7d1e7f81240a230812d54913d2d700f67e Mon Sep 17 00:00:00 2001 From: Austin Burdine Date: Tue, 4 Jul 2017 15:03:46 -0400 Subject: [PATCH] fix(config): fix config environment handling closes #265 - run checkEnvironment call in config class during get/set --- lib/commands/config/index.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/commands/config/index.js b/lib/commands/config/index.js index ab921eb9b..1b9c8d39a 100644 --- a/lib/commands/config/index.js +++ b/lib/commands/config/index.js @@ -13,8 +13,7 @@ class ConfigCommand extends Command { constructor(ui, system) { super(ui, system); - let instance = this.system.getInstance(); - this.config = instance.config; + this.instance = this.system.getInstance(); } handleAdvancedOptions(argv) { @@ -29,11 +28,11 @@ class ConfigCommand extends Command { } let defaultValue = isFunction(option.defaultValue) ? - option.defaultValue(this.config, this.system.environment) : + option.defaultValue(this.instance.config, this.system.environment) : option.defaultValue; return Promise.resolve(defaultValue).then((result) => { - this.config.set(configKey, result); + this.instance.config.set(configKey, result); }); } @@ -47,7 +46,7 @@ class ConfigCommand extends Command { })); } - this.config.set(configKey, value); + this.instance.config.set(configKey, value); }); }).then(() => { // Because the 'port' option can end up being different than the one supplied @@ -59,10 +58,10 @@ class ConfigCommand extends Command { // url.format won't take the new port unless 'parsedUrl.host' is undefined delete parsedUrl.host; - this.config.set('url', url.format(parsedUrl)); + this.instance.config.set('url', url.format(parsedUrl)); } - this.config.save(); + this.instance.config.save(); }); } @@ -101,8 +100,9 @@ class ConfigCommand extends Command { }]; if (key && !value) { + this.instance.checkEnvironment(); // getter - value = this.config.get(key, null); + value = this.instance.config.get(key, null); if (value) { this.ui.log(value); @@ -110,8 +110,9 @@ class ConfigCommand extends Command { return Promise.resolve(); } else if (key) { + this.instance.checkEnvironment(); // setter - this.config.set(key, value).save(); + this.instance.config.set(key, value).save(); return Promise.resolve(); }