mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-11 22:34:24 +00:00
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() {
|
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');
|
//var configPlugins = this.plugins.getPluginsFor('storageConfig');
|
||||||
//if (configPlugins.length > 0) {
|
//if (configPlugins.length > 0) {
|
||||||
@ -106,8 +117,12 @@ Config.prototype.loadStorageConfigFile = function() {
|
|||||||
// });
|
// });
|
||||||
//}
|
//}
|
||||||
|
|
||||||
var storageConfig = fs.readJSONSync(this.configDir + "storage.json");
|
var storageConfig;
|
||||||
configObject = utils.recursiveMerge(configObject, 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 defaultStorageConfig = configObject['default'];
|
||||||
var envStorageConfig = configObject[this.env];
|
var envStorageConfig = configObject[this.env];
|
||||||
|
|
||||||
@ -123,7 +138,13 @@ Config.prototype.loadStorageConfigFile = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Config.prototype.loadCommunicationConfigFile = function() {
|
Config.prototype.loadCommunicationConfigFile = function() {
|
||||||
var configObject = {};
|
var configObject = {
|
||||||
|
"default": {
|
||||||
|
"enabled": true,
|
||||||
|
"provider": "whisper",
|
||||||
|
"available_providers": ["whisper", "orbit"]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
//var configPlugins = this.plugins.getPluginsFor('communicationConfig');
|
//var configPlugins = this.plugins.getPluginsFor('communicationConfig');
|
||||||
//if (configPlugins.length > 0) {
|
//if (configPlugins.length > 0) {
|
||||||
@ -134,14 +155,20 @@ Config.prototype.loadCommunicationConfigFile = function() {
|
|||||||
// });
|
// });
|
||||||
//}
|
//}
|
||||||
|
|
||||||
var communicationConfig = fs.readJSONSync(this.configDir + "communication.json");
|
var communicationConfig;
|
||||||
configObject = utils.recursiveMerge(configObject, 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 defaultCommunicationConfig = configObject['default'];
|
||||||
var envCommunicationConfig = configObject[this.env];
|
var envCommunicationConfig = configObject[this.env];
|
||||||
|
|
||||||
var mergedConfig = utils.recursiveMerge(defaultCommunicationConfig, envCommunicationConfig);
|
var mergedConfig = utils.recursiveMerge(defaultCommunicationConfig, envCommunicationConfig);
|
||||||
this.communicationConfig = mergedConfig || {};
|
this.communicationConfig = mergedConfig || {};
|
||||||
|
|
||||||
|
// TODO: probably not necessary if the default object is done right
|
||||||
if (this.communicationConfig.enabled === undefined) {
|
if (this.communicationConfig.enabled === undefined) {
|
||||||
this.communicationConfig.enabled = true;
|
this.communicationConfig.enabled = true;
|
||||||
}
|
}
|
||||||
@ -151,7 +178,12 @@ Config.prototype.loadCommunicationConfigFile = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Config.prototype.loadWebServerConfigFile = 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 = {
|
var defaultWebConfig = {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"host": "localhost",
|
"host": "localhost",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user