Skip to content

Commit 670a09e

Browse files
committed
Better error management
1 parent a9b8fb2 commit 670a09e

File tree

5 files changed

+20
-5
lines changed

5 files changed

+20
-5
lines changed

cli.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ program
3434
.option(
3535
"-e, --execute <command>",
3636
"Start ethnode, execute command, and exit ethnode (useful for testing)."
37-
)
37+
);
3838

3939
program.version(packageJson.version);
4040

get_geth.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33

44
# Note: $HOMEDIR is defined in main.js, check it out
55

6+
set -e
7+
68
PLATFORM=$(uname | tr '[:upper:]' '[:lower:]')
79
ARCH=$(uname -m)
810

911
VERSION=$(curl -s https://api.github.com/repos/ethereum/go-ethereum/releases/latest | python -c "import sys, json; print(json.load(sys.stdin)['tag_name'])")
1012
COMMIT=$(curl -s https://api.github.com/repos/ethereum/go-ethereum/commits/${VERSION} | python -c "import sys, json; print(json.load(sys.stdin)['sha'])")
1113
NAME="geth-${PLATFORM}-amd64-${VERSION:1}-${COMMIT:0:8}"
1214
DOWNLOAD_URL="https://gethstore.blob.core.windows.net/builds/${NAME}.tar.gz"
13-
curl ${DOWNLOAD_URL} | tar -Oxzf - ${NAME}/geth > ${HOMEDIR}/geth
15+
TMP_FILE=$(mktemp)
16+
curl --fail ${DOWNLOAD_URL} | tar -Oxzf - ${NAME}/geth > ${TMP_FILE}
17+
mv ${TMP_FILE} ${HOMEDIR}/geth
1418
chmod +x ${HOMEDIR}/geth

main.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,17 @@ function downloadClient(client, workdir) {
8787

8888
if (!fs.existsSync(paths.binary)) {
8989
console.log(`Download latest ${client} version, please wait.`);
90-
spawnSync(path.join(__dirname, `get_${client}.sh`), {
90+
const childResult = spawnSync(path.join(__dirname, `get_${client}.sh`), {
9191
env: { HOMEDIR },
9292
stdio: "inherit"
9393
});
94+
if (childResult.status !== 0) {
95+
console.log(
96+
`Error downloading ${client}, this might be temporary, ` +
97+
`try again later.`
98+
);
99+
process.exit(childResult.status);
100+
}
94101
}
95102
}
96103

@@ -131,6 +138,10 @@ function provide(client, workdir, allocate, execute, loggingOptions) {
131138
}
132139
);
133140
if (childResult.status !== 0) {
141+
console.log(
142+
`Error running ${paths.binary}, run it manually to check if it ` +
143+
`works or not. If it doesn't, remove it and run ethnode again.`
144+
);
134145
process.exit(childResult.status);
135146
}
136147
}

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
@@ -6,7 +6,7 @@
66
"main": "main.js",
77
"scripts": {
88
"test": "echo \"Error: no test specified\" && exit 1",
9-
"install": "ethnode -d"
9+
"postinstall": "./cli.js -d"
1010
},
1111
"bin": "./cli.js",
1212
"author": "vrde",

0 commit comments

Comments
 (0)