Merge pull request #218 from nogueian/develop

Prevent node exception when running command 'embark blockchain'
This commit is contained in:
Iuri Matias 2017-02-21 18:44:08 -05:00 committed by GitHub
commit 9930a9024a
2 changed files with 13 additions and 1 deletions

View File

@ -23,6 +23,14 @@ Config.prototype.loadConfigFiles = function(options) {
if (options.interceptLogs === undefined) {
interceptLogs = true;
}
//Check if the config file exists
var embarkConfigExists = fs.existsSync(options.embarkConfig);
if(!embarkConfigExists){
this.logger.error('Cannot find file ' + options.embarkConfig + '. Please ensure you are running this command inside the Dapp folder');
process.exit(1);
}
this.embarkConfig = fs.readJSONSync(options.embarkConfig);
this.embarkConfig.plugins = this.embarkConfig.plugins || {};

View File

@ -25,6 +25,10 @@ function writeJSONSync() {
return fs.writeJSONSync.apply(fs.writeJSONSync, arguments);
}
function existsSync(){
return fs.existsSync.apply(fs.existsSync, arguments);
}
// returns embarks root directory
function embarkPath(fileOrDir) {
return utils.joinPath(__dirname, '/../../', fileOrDir);
@ -37,6 +41,6 @@ module.exports = {
writeFileSync: writeFileSync,
readJSONSync: readJSONSync,
writeJSONSync: writeJSONSync,
existsSync: existsSync,
embarkPath: embarkPath
};