Skip to content

Commit

Permalink
fix(config): fix config environment handling
Browse files Browse the repository at this point in the history
closes #265
- run checkEnvironment call in config class during get/set
  • Loading branch information
acburdine committed Jul 4, 2017
1 parent 3c56f2e commit 0a75eb7
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions lib/commands/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
});
}

Expand All @@ -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
Expand All @@ -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();
});
}

Expand Down Expand Up @@ -101,17 +100,19 @@ 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);
}

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();
}

Expand Down

0 comments on commit 0a75eb7

Please sign in to comment.