check if geth command exists and warn user if not

This commit is contained in:
Iuri Matias 2017-12-13 17:58:07 -05:00
parent 18d6aafd60
commit d32d5f50bd
2 changed files with 18 additions and 2 deletions

View File

@ -50,12 +50,26 @@ Blockchain.prototype.run = function() {
console.log(("Embark Blockchain Using: " + this.client.name.underline).magenta);
console.log("===============================================================================".magenta);
console.log("===============================================================================".magenta);
if (!this.isClientInstalled()) {
console.log(("could not find " + this.config.geth_bin + " command; is " + this.client.name + " installed or in the PATH?").green);
return;
}
var address = this.initChainAndGetAddress();
this.client.mainCommand(address, function(cmd) {
self.runCommand(cmd, {async: true});
});
};
Blockchain.prototype.isClientInstalled = function() {
let versionCmd = this.client.determineVersion();
let result = this.runCommand(versionCmd);
if (result.output === undefined || result.output.indexOf("not found") >= 0) {
return false;
}
return true;
};
Blockchain.prototype.initChainAndGetAddress = function() {
var address = null, result;
@ -94,4 +108,3 @@ var BlockchainClient = function(blockchainConfig, client, env) {
};
module.exports = BlockchainClient;

View File

@ -34,6 +34,10 @@ class GethCommands {
return cmd;
}
determineVersion() {
return this.geth_bin + " version";
}
determineNetworkType(config) {
let cmd = "";
if (config.networkType === 'testnet') {
@ -203,4 +207,3 @@ class GethCommands {
}
module.exports = GethCommands;