Fixed logic to prevent node exception when running command 'embark blockchain' outside the Dapp folder

This commit is contained in:
Andy Nogueira 2017-02-21 15:45:10 -05:00
parent 0e03d8f435
commit dd03c747f7
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
};