refactor(@embark/plugins/geth): don't run empty commands

The `WhisperGethClient` returns empty strings for its "new account" and "list
accounts" commands; if a command is an empty string then `Blockchain` should
not execute it.
This commit is contained in:
Michael Bradley, Jr 2019-11-07 13:02:16 -06:00 committed by Michael Bradley
parent 2543acad75
commit 7b991bb58a
1 changed files with 6 additions and 2 deletions

View File

@ -313,7 +313,9 @@ Blockchain.prototype.initDevChain = function(callback) {
// Create other accounts
async.waterfall([
function listAccounts(next) {
self.runCommand(self.client.listAccountsCommand(), {}, (err, stdout, _stderr) => {
const listAccountsCommand = self.client.listAccountsCommand();
if (!listAccountsCommand) return next(null, 0);
self.runCommand(listAccountsCommand, {}, (err, stdout, _stderr) => {
if (err || stdout === undefined || stdout.indexOf("Fatal") >= 0) {
console.log(__("no accounts found").green);
return next();
@ -330,6 +332,8 @@ Blockchain.prototype.initDevChain = function(callback) {
});
},
function newAccounts(accountsToCreate, next) {
const newAccountCommand = self.client.newAccountCommand();
if (!newAccountCommand) return next();
var accountNumber = 0;
async.whilst(
function() {
@ -337,7 +341,7 @@ Blockchain.prototype.initDevChain = function(callback) {
},
function(callback) {
accountNumber++;
self.runCommand(self.client.newAccountCommand(), {}, (err, stdout, _stderr) => {
self.runCommand(newAccountCommand, {}, (err, stdout, _stderr) => {
if (err) {
return callback(err, accountNumber);
}