Skip to content

Commit 0a75eb7

Browse files
committed
fix(config): fix config environment handling
closes #265 - run checkEnvironment call in config class during get/set
1 parent 3c56f2e commit 0a75eb7

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

lib/commands/config/index.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ class ConfigCommand extends Command {
1313
constructor(ui, system) {
1414
super(ui, system);
1515

16-
let instance = this.system.getInstance();
17-
this.config = instance.config;
16+
this.instance = this.system.getInstance();
1817
}
1918

2019
handleAdvancedOptions(argv) {
@@ -29,11 +28,11 @@ class ConfigCommand extends Command {
2928
}
3029

3130
let defaultValue = isFunction(option.defaultValue) ?
32-
option.defaultValue(this.config, this.system.environment) :
31+
option.defaultValue(this.instance.config, this.system.environment) :
3332
option.defaultValue;
3433

3534
return Promise.resolve(defaultValue).then((result) => {
36-
this.config.set(configKey, result);
35+
this.instance.config.set(configKey, result);
3736
});
3837
}
3938

@@ -47,7 +46,7 @@ class ConfigCommand extends Command {
4746
}));
4847
}
4948

50-
this.config.set(configKey, value);
49+
this.instance.config.set(configKey, value);
5150
});
5251
}).then(() => {
5352
// Because the 'port' option can end up being different than the one supplied
@@ -59,10 +58,10 @@ class ConfigCommand extends Command {
5958
// url.format won't take the new port unless 'parsedUrl.host' is undefined
6059
delete parsedUrl.host;
6160

62-
this.config.set('url', url.format(parsedUrl));
61+
this.instance.config.set('url', url.format(parsedUrl));
6362
}
6463

65-
this.config.save();
64+
this.instance.config.save();
6665
});
6766
}
6867

@@ -101,17 +100,19 @@ class ConfigCommand extends Command {
101100
}];
102101

103102
if (key && !value) {
103+
this.instance.checkEnvironment();
104104
// getter
105-
value = this.config.get(key, null);
105+
value = this.instance.config.get(key, null);
106106

107107
if (value) {
108108
this.ui.log(value);
109109
}
110110

111111
return Promise.resolve();
112112
} else if (key) {
113+
this.instance.checkEnvironment();
113114
// setter
114-
this.config.set(key, value).save();
115+
this.instance.config.set(key, value).save();
115116
return Promise.resolve();
116117
}
117118

0 commit comments

Comments
 (0)