check if geth command exists and warn user if not
This commit is contained in:
parent
18d6aafd60
commit
d32d5f50bd
|
@ -50,12 +50,26 @@ Blockchain.prototype.run = function() {
|
||||||
console.log(("Embark Blockchain Using: " + this.client.name.underline).magenta);
|
console.log(("Embark Blockchain Using: " + this.client.name.underline).magenta);
|
||||||
console.log("===============================================================================".magenta);
|
console.log("===============================================================================".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();
|
var address = this.initChainAndGetAddress();
|
||||||
this.client.mainCommand(address, function(cmd) {
|
this.client.mainCommand(address, function(cmd) {
|
||||||
self.runCommand(cmd, {async: true});
|
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() {
|
Blockchain.prototype.initChainAndGetAddress = function() {
|
||||||
var address = null, result;
|
var address = null, result;
|
||||||
|
|
||||||
|
@ -94,4 +108,3 @@ var BlockchainClient = function(blockchainConfig, client, env) {
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = BlockchainClient;
|
module.exports = BlockchainClient;
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,10 @@ class GethCommands {
|
||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
determineVersion() {
|
||||||
|
return this.geth_bin + " version";
|
||||||
|
}
|
||||||
|
|
||||||
determineNetworkType(config) {
|
determineNetworkType(config) {
|
||||||
let cmd = "";
|
let cmd = "";
|
||||||
if (config.networkType === 'testnet') {
|
if (config.networkType === 'testnet') {
|
||||||
|
@ -203,4 +207,3 @@ class GethCommands {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = GethCommands;
|
module.exports = GethCommands;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue