Merge pull request #628 from embark-framework/features/invoke-local-ganache-cli-directly

invoke embark's local ganache-cli directly
This commit is contained in:
Michael Bradley 2018-07-13 08:15:30 -05:00 committed by GitHub
commit 07f600f756
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 16 deletions

View File

@ -1,3 +1,4 @@
const path = require('path');
let shelljs = require('shelljs'); let shelljs = require('shelljs');
let proxy = require('../core/proxy'); let proxy = require('../core/proxy');
const Ipc = require('../core/ipc'); const Ipc = require('../core/ipc');
@ -12,23 +13,14 @@ class Simulator {
run(options) { run(options) {
let cmds = []; let cmds = [];
const ganache = shelljs.which('ganache-cli-embark'); const ganache = path.join(__dirname, '../../node_modules/.bin/ganache-cli');
// const testrpc = shelljs.which('testrpc');
// const ganache = shelljs.which('ganache-cli');
// if (!testrpc && !ganache) {
// this.logger.warn(__('%s is not installed on your machine', 'Ganache CLI (TestRPC)'));
// this.logger.info(__('You can install it by running: %s', 'npm -g install ganache-cli'));
// process.exit();
// }
let useProxy = this.blockchainConfig.proxy || false; let useProxy = this.blockchainConfig.proxy || false;
let host = (options.host || this.blockchainConfig.rpcHost || 'localhost'); let host = (options.host || this.blockchainConfig.rpcHost || 'localhost');
let port = (options.port || this.blockchainConfig.rpcPort || 8545); let port = (options.port || this.blockchainConfig.rpcPort || 8545);
cmds.push("-p " + (port + (useProxy ? constants.blockchain.servicePortOnProxy : 0))); cmds.push("-p " + (port + (useProxy ? constants.blockchain.servicePortOnProxy : 0)));
if (!ganache) {
cmds.push("-h " + host); cmds.push("-h " + host);
}
cmds.push("-a " + (options.numAccounts || 10)); cmds.push("-a " + (options.numAccounts || 10));
cmds.push("-e " + (options.defaultBalance || 100)); cmds.push("-e " + (options.defaultBalance || 100));
cmds.push("-l " + (options.gasLimit || 8000000)); cmds.push("-l " + (options.gasLimit || 8000000));
@ -45,8 +37,6 @@ class Simulator {
cmds.push("-b \"" + (simulatorBlocktime) +"\""); cmds.push("-b \"" + (simulatorBlocktime) +"\"");
} }
// const programName = ganache ? 'ganache-cli' : 'testrpc';
// const program = ganache ? ganache : testrpc;
const programName = 'ganache-cli'; const programName = 'ganache-cli';
const program = ganache; const program = ganache;
console.log(`running: ${programName} ${cmds.join(' ')}`); console.log(`running: ${programName} ${cmds.join(' ')}`);
@ -56,7 +46,6 @@ class Simulator {
let ipcObject = new Ipc({ipcRole: 'client'}); let ipcObject = new Ipc({ipcRole: 'client'});
proxy.serve(ipcObject, host, port, false); proxy.serve(ipcObject, host, port, false);
} }
} }
} }

View File

@ -10,8 +10,7 @@
"fulltest": "npm run lint && npm run test && npm run testdapp_1 && npm run testdapp_2" "fulltest": "npm run lint && npm run test && npm run testdapp_1 && npm run testdapp_2"
}, },
"bin": { "bin": {
"embark": "./bin/embark", "embark": "./bin/embark"
"ganache-cli-embark": "./node_modules/.bin/ganache-cli"
}, },
"main": "./lib/index.js", "main": "./lib/index.js",
"directories": { "directories": {