mirror of https://github.com/embarklabs/embark.git
support js files besides json files
This commit is contained in:
parent
bd0e4a9960
commit
8b22305833
|
@ -75,7 +75,7 @@ Config.prototype._mergeConfig = function(configFilePath, defaultConfig, env, ena
|
|||
return configToReturn;
|
||||
}
|
||||
|
||||
if (!fs.existsSync(configFilePath)) {
|
||||
if (!fs.existsSync(configFilePath + '.js') && !fs.existsSync(configFilePath + ' .json')) {
|
||||
// TODO: remove this if
|
||||
if (this.logger) {
|
||||
this.logger.warn(__("no config file found at %s using default config", configFilePath));
|
||||
|
@ -83,7 +83,12 @@ Config.prototype._mergeConfig = function(configFilePath, defaultConfig, env, ena
|
|||
return defaultConfig['default'] || {};
|
||||
}
|
||||
|
||||
let config = fs.readJSONSync(configFilePath);
|
||||
let config;
|
||||
if (fs.existsSync(configFilePath + '.js')) {
|
||||
config = require(fs.dappPath(configFilePath + '.js'));
|
||||
} else {
|
||||
config = fs.readJSONSync(configFilePath);
|
||||
}
|
||||
let configObject = utils.recursiveMerge(defaultConfig, config);
|
||||
|
||||
if (env) {
|
||||
|
@ -109,7 +114,7 @@ Config.prototype.loadBlockchainConfigFile = function() {
|
|||
}
|
||||
};
|
||||
|
||||
let configFilePath = this._getFileOrOject(this.configDir, 'blockchain.json', 'blockchain');
|
||||
let configFilePath = this._getFileOrOject(this.configDir, 'blockchain', 'blockchain');
|
||||
|
||||
this.blockchainConfig = this._mergeConfig(configFilePath, configObject, this.env, true);
|
||||
};
|
||||
|
@ -142,7 +147,7 @@ Config.prototype.loadContractsConfigFile = function() {
|
|||
configObject = utils.recursiveMerge(configObject, pluginConfig);
|
||||
});
|
||||
|
||||
let configFilePath = this._getFileOrOject(this.configDir, 'contracts.json', 'contracts');
|
||||
let configFilePath = this._getFileOrOject(this.configDir, 'contracts', 'contracts');
|
||||
|
||||
const newContractsConfig = this._mergeConfig(configFilePath, configObject, this.env);
|
||||
|
||||
|
@ -193,7 +198,7 @@ Config.prototype.loadStorageConfigFile = function() {
|
|||
}
|
||||
};
|
||||
|
||||
let configFilePath = this._getFileOrOject(this.configDir, 'storage.json', 'storage');
|
||||
let configFilePath = this._getFileOrOject(this.configDir, 'storage', 'storage');
|
||||
|
||||
this.storageConfig = this._mergeConfig(configFilePath, configObject, this.env);
|
||||
};
|
||||
|
@ -210,7 +215,7 @@ Config.prototype.loadCommunicationConfigFile = function() {
|
|||
}
|
||||
};
|
||||
|
||||
let configFilePath = this._getFileOrOject(this.configDir, 'communication.json', 'communication');
|
||||
let configFilePath = this._getFileOrOject(this.configDir, 'communication', 'communication');
|
||||
|
||||
this.communicationConfig = this._mergeConfig(configFilePath, configObject, this.env);
|
||||
};
|
||||
|
@ -220,7 +225,7 @@ Config.prototype.loadWebServerConfigFile = function() {
|
|||
"enabled": true, "host": "localhost", "port": 8000
|
||||
};
|
||||
|
||||
let configFilePath = this._getFileOrOject(this.configDir, 'webserver.json', 'webserver');
|
||||
let configFilePath = this._getFileOrOject(this.configDir, 'webserver', 'webserver');
|
||||
|
||||
this.webServerConfig = this._mergeConfig(configFilePath, configObject, false);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue