diff --git a/findClient.js b/findClient.js new file mode 100644 index 0000000000..8ceb9bce00 --- /dev/null +++ b/findClient.js @@ -0,0 +1,43 @@ +var which = require('which') + +var geth = null +var eth = null + +try { + geth = which.sync('geth') +} catch (e) { +} + +try { + eth = which.sync('eth') +} catch (e) { +} +if (process.argv.length > 2) { + if (geth && process.argv[2] === 'geth') { + runGeth() + } else if (eth && process.argv[2] === 'eth') { + runEth() + } +} else if (geth && eth) { + console.log('both eth and geth has been found in your system') + console.log('restart the command with the desired client:') + console.log('npm run start_eth') + console.log('or') + console.log('npm run start_geth') +} else if (geth) { + runGeth() +} else if (eth) { + runEth() +} else { + console.log('neither eth or geth has been found in your system') +} + +function runEth () { + console.log('starting eth...') + process.exit(20) +} + +function runGeth () { + console.log('starting geth...') + process.exit(21) +} diff --git a/npm-debug.log.2094563598 b/npm-debug.log.2094563598 deleted file mode 100644 index d43c27392b..0000000000 --- a/npm-debug.log.2094563598 +++ /dev/null @@ -1,20 +0,0 @@ -0 info it worked if it ends with ok -1 verbose cli [ '/usr/bin/nodejs', '/usr/bin/npm', 'config', 'get', 'prefix' ] -2 info using npm@3.8.6 -3 info using node@v5.12.0 -4 verbose exit [ 0, true ] -5 verbose stack Error: write EPIPE -5 verbose stack at exports._errnoException (util.js:893:11) -5 verbose stack at WriteWrap.afterWrite (net.js:783:14) -6 verbose cwd /home/yann/Ethereum/remix/fea1/remix -7 error Linux 3.16.0-30-generic -8 error argv "/usr/bin/nodejs" "/usr/bin/npm" "config" "get" "prefix" -9 error node v5.12.0 -10 error npm v3.8.6 -11 error code EPIPE -12 error errno EPIPE -13 error syscall write -14 error write EPIPE -15 error If you need help, you may report this error at: -15 error -16 verbose exit [ 1, true ] diff --git a/package.json b/package.json index 555872884d..d3b2bd054d 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,9 @@ } ], "main": "./src/index.js", + "dependencies": { + "which": "^1.2.10" + }, "devDependencies": { "browserify": "^13.0.1", "ethereumjs-util": "^4.5.0", @@ -26,7 +29,9 @@ "yo-yoify": "^3.1.0" }, "scripts": { - "start_node": "eth --rpccorsdomain \"*\" -j -v 0", + "start_node": "./runNode.sh", + "start_eth": "eth -j --rpccorsdomain '*'", + "start_geth": "geth --rpc --rpcapi 'web3,eth,debug' --rpcport 8545 --rpccorsdomain '*'", "build": "mkdir -p build; browserify src/index.js -g yo-yoify -o build/app.js", "test": "standard && tape ./test/tests.js", "serve": "http-server .", diff --git a/runNode.sh b/runNode.sh new file mode 100755 index 0000000000..79575a46f2 --- /dev/null +++ b/runNode.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +node findClient.js $1 +RUNCLIENT=$? +if [ $RUNCLIENT -eq '20' ] +then + npm run start_eth +fi + +if [ $RUNCLIENT -eq '21' ] +then + echo $? + npm run start_geth +fi \ No newline at end of file