mirror of https://github.com/embarklabs/embark.git
support defaults when new config files are not found, for backwards compatibility
This commit is contained in:
parent
007be84f23
commit
96d1361dd8
|
@ -95,7 +95,18 @@ Config.prototype.loadContractsConfigFile = function() {
|
|||
|
||||
|
||||
Config.prototype.loadStorageConfigFile = function() {
|
||||
var configObject = {};
|
||||
var configObject = {
|
||||
"default": {
|
||||
"enabled": true,
|
||||
"available_providers": ["ipfs"],
|
||||
"ipfs_bin": "ipfs",
|
||||
"provider": "ipfs",
|
||||
"host": "localhost",
|
||||
"port": 5001
|
||||
},
|
||||
"development": {
|
||||
}
|
||||
};
|
||||
|
||||
//var configPlugins = this.plugins.getPluginsFor('storageConfig');
|
||||
//if (configPlugins.length > 0) {
|
||||
|
@ -106,8 +117,12 @@ Config.prototype.loadStorageConfigFile = function() {
|
|||
// });
|
||||
//}
|
||||
|
||||
var storageConfig = fs.readJSONSync(this.configDir + "storage.json");
|
||||
var storageConfig;
|
||||
if (fs.existsSync(this.configDir + "storage.json")) {
|
||||
storageConfig = fs.readJSONSync(this.configDir + "storage.json");
|
||||
configObject = utils.recursiveMerge(configObject, storageConfig);
|
||||
}
|
||||
|
||||
var defaultStorageConfig = configObject['default'];
|
||||
var envStorageConfig = configObject[this.env];
|
||||
|
||||
|
@ -123,7 +138,13 @@ Config.prototype.loadStorageConfigFile = function() {
|
|||
};
|
||||
|
||||
Config.prototype.loadCommunicationConfigFile = function() {
|
||||
var configObject = {};
|
||||
var configObject = {
|
||||
"default": {
|
||||
"enabled": true,
|
||||
"provider": "whisper",
|
||||
"available_providers": ["whisper", "orbit"]
|
||||
}
|
||||
};
|
||||
|
||||
//var configPlugins = this.plugins.getPluginsFor('communicationConfig');
|
||||
//if (configPlugins.length > 0) {
|
||||
|
@ -134,14 +155,20 @@ Config.prototype.loadCommunicationConfigFile = function() {
|
|||
// });
|
||||
//}
|
||||
|
||||
var communicationConfig = fs.readJSONSync(this.configDir + "communication.json");
|
||||
var communicationConfig;
|
||||
|
||||
if (fs.existsSync(this.configDir + "communication.json")) {
|
||||
communicationConfig = fs.readJSONSync(this.configDir + "communication.json");
|
||||
configObject = utils.recursiveMerge(configObject, communicationConfig);
|
||||
}
|
||||
|
||||
var defaultCommunicationConfig = configObject['default'];
|
||||
var envCommunicationConfig = configObject[this.env];
|
||||
|
||||
var mergedConfig = utils.recursiveMerge(defaultCommunicationConfig, envCommunicationConfig);
|
||||
this.communicationConfig = mergedConfig || {};
|
||||
|
||||
// TODO: probably not necessary if the default object is done right
|
||||
if (this.communicationConfig.enabled === undefined) {
|
||||
this.communicationConfig.enabled = true;
|
||||
}
|
||||
|
@ -151,7 +178,12 @@ Config.prototype.loadCommunicationConfigFile = function() {
|
|||
};
|
||||
|
||||
Config.prototype.loadWebServerConfigFile = function() {
|
||||
var webServerConfigJSON = fs.readJSONSync(this.configDir + "webserver.json");
|
||||
var webServerConfigJSON;
|
||||
if (fs.existsSync(this.configDir + "webserver.json")) {
|
||||
webServerConfigJSON = fs.readJSONSync(this.configDir + "webserver.json");
|
||||
} else {
|
||||
webServerConfigJSON = {};
|
||||
}
|
||||
var defaultWebConfig = {
|
||||
"enabled": true,
|
||||
"host": "localhost",
|
||||
|
|
Loading…
Reference in New Issue