Skip to content

Commit e58671e

Browse files
committed
refactor common geth command options into the a common method
1 parent 0a2a26f commit e58671e

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

lib/geth_commands.js

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ GethCommands.prototype.newAccountCommand = function() {
4646
return cmd + "account new ";
4747
};
4848

49-
GethCommands.prototype.listAccountsCommand = function() {
49+
GethCommands.prototype.commonOptions = function() {
5050
var config = this.config;
51-
var cmd = "geth ";
51+
var cmd = "";
5252

5353
if (config.networkType === 'testnet') {
5454
cmd += "--testnet ";
@@ -66,29 +66,19 @@ GethCommands.prototype.listAccountsCommand = function() {
6666
cmd += "--password " + config.account.password + " ";
6767
}
6868

69-
return cmd + "account list ";
69+
return cmd;
70+
};
71+
72+
GethCommands.prototype.listAccountsCommand = function() {
73+
return "geth " + this.commonOptions() + "account list ";
7074
};
7175

7276
GethCommands.prototype.mainCommand = function(address) {
7377
var config = this.config;
7478
var cmd = "geth ";
7579
var rpc_api = ['eth', 'web3'];
7680

77-
if (config.datadir) {
78-
cmd += "--datadir=\"" + config.datadir + "\" ";
79-
}
80-
81-
if (config.networkType === 'testnet') {
82-
cmd += "--testnet ";
83-
} else if (config.networkType === 'olympic') {
84-
cmd += "--olympic ";
85-
} else if (config.networkType === 'custom') {
86-
cmd += "--networkid " + config.networkId + " ";
87-
}
88-
89-
if (config.account && config.account.password) {
90-
cmd += "--password " + config.account.password + " ";
91-
}
81+
cmd += this.commonOptions();
9282

9383
cmd += "--port " + "30303" + " ";
9484
cmd += "--rpc ";

0 commit comments

Comments
 (0)