File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -3,11 +3,20 @@ let shelljs = require('shelljs');
33class Simulator {
44 constructor ( options ) {
55 this . blockchainConfig = options . blockchainConfig ;
6+ this . logger = options . logger ;
67 }
78
89 run ( options ) {
910 let cmds = [ ] ;
1011
12+ const testrpc = shelljs . which ( 'testrpc' ) ;
13+ const ganache = shelljs . which ( 'ganache-cli' ) ;
14+ if ( ! testrpc && ! ganache ) {
15+ this . logger . warn ( 'Ganache CLI (TestRPC) is not installed on your machine' ) ;
16+ this . logger . info ( 'You can install it by running: npm -g install ganache-cli' ) ;
17+ process . exit ( ) ;
18+ }
19+
1120 cmds . push ( "-p " + ( this . blockchainConfig . rpcPort || options . port || 8545 ) ) ;
1221 cmds . push ( "-h " + ( this . blockchainConfig . rpcHost || options . host || 'localhost' ) ) ;
1322 cmds . push ( "-a " + ( options . numAccounts || 10 ) ) ;
@@ -26,7 +35,8 @@ class Simulator {
2635 cmds . push ( "-b \"" + ( simulatorBlocktime ) + "\"" ) ;
2736 }
2837
29- shelljs . exec ( 'testrpc ' + cmds . join ( ' ' ) , { async : true } ) ;
38+ const program = ganache ? 'ganache-cli' : 'testrpc' ;
39+ shelljs . exec ( `${ program } ${ cmds . join ( ' ' ) } ` , { async : true } ) ;
3040 }
3141}
3242
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ class Embark {
5757 simulator ( options ) {
5858 this . context = options . context || [ constants . contexts . simulator , constants . contexts . blockchain ] ;
5959 let Simulator = require ( './cmds/simulator.js' ) ;
60- let simulator = new Simulator ( { blockchainConfig : this . config . blockchainConfig } ) ;
60+ let simulator = new Simulator ( { blockchainConfig : this . config . blockchainConfig , logger : this . logger } ) ;
6161 simulator . run ( options ) ;
6262 }
6363
You can’t perform that action at this time.
0 commit comments