Skip to content

Commit 6f2c86c

Browse files
committed
Add option to only download binary
1 parent aceabb1 commit 6f2c86c

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

cli.js

+9-10
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,16 @@ const packageJson = require("./package.json");
99

1010
var noAction = true;
1111

12-
function workdir() {
13-
if (program.workdir) {
14-
return program.workdir;
15-
} else {
16-
const tmpDir = os.tmpdir();
17-
return fs.mkdtempSync(`${tmpDir}${sep}`);
18-
}
12+
function getOptions(program) {
13+
return {
14+
workdir: program.workdir || fs.mkdtempSync(`${os.tmpdir()}${sep}`),
15+
download: program.download
16+
};
1917
}
2018

2119
program
2220
.version(packageJson.version)
21+
.option("-d, --download", "Download the Ethereum client and exit.")
2322
.option("-w, --workdir <dir>", "Specify a working dir.");
2423

2524
program.version(packageJson.version);
@@ -29,19 +28,19 @@ program
2928
.description("Run a Parity development node.")
3029
.action(cmd => {
3130
noAction = false;
32-
run("parity", workdir());
31+
run("parity", getOptions(program));
3332
});
3433

3534
program
3635
.command("geth")
3736
.description("Run a Geth development node.")
3837
.action(cmd => {
3938
noAction = false;
40-
run("geth", workdir());
39+
run("geth", getOptions(program));
4140
});
4241

4342
program.parse(process.argv);
4443

4544
if (noAction) {
46-
run("geth", workdir());
45+
run("geth", getOptions(program));
4746
}

main.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function generateBalances(keypairs, balance) {
5757
return balances;
5858
}
5959

60-
function setup(client, workdir) {
60+
function downloadClient(client, workdir) {
6161
const paths = getPaths(client, workdir);
6262
if (!fs.existsSync(paths.binary)) {
6363
console.log(`Download latest ${client} version, please wait.`);
@@ -108,9 +108,12 @@ function provide(client, workdir) {
108108
}
109109
}
110110

111-
function run(client, workdir) {
111+
function run(client, { download, workdir }) {
112112
const paths = getPaths(client, workdir);
113-
setup(client, workdir);
113+
downloadClient(client, workdir);
114+
if (download) {
115+
return;
116+
}
114117
if (!fs.existsSync(paths.genesis)) {
115118
provide(client, workdir);
116119
}

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ethnode",
3-
"version": "0.0.10",
3+
"version": "0.0.11",
44
"description": "Run an Ethereum node for development.",
55
"homepage": "https://github.com/vrde/ethnode",
66
"main": "main.js",

0 commit comments

Comments
 (0)