mirror of https://github.com/embarklabs/embark.git
take configuration options from config and command line arguments when running simulator
This commit is contained in:
parent
e09e40e3ba
commit
566812696d
13
lib/cmd.js
13
lib/cmd.js
|
@ -103,13 +103,18 @@ Cmd.prototype.blockchain = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
Cmd.prototype.simulator = function() {
|
Cmd.prototype.simulator = function() {
|
||||||
|
var self = this;
|
||||||
program
|
program
|
||||||
.command('simulator')
|
.command('simulator [environment]')
|
||||||
.description('run a fast ethereum rpc simulator')
|
.description('run a fast ethereum rpc simulator')
|
||||||
.option('--testrpc', 'use testrpc as the rpc simulator [default]')
|
.option('--testrpc', 'use testrpc as the rpc simulator [default]')
|
||||||
.action(function(options) {
|
.option('-p, --port [port]', 'port to run the rpc simulator (default: 8000)')
|
||||||
//console.log('TestRPC not found; Please install it with "npm install -g ethereumjs-testrpc');
|
.option('-h, --host [host]', 'host to run the rpc simulator (default: localhost)')
|
||||||
exec('testrpc');
|
.action(function(env, options) {
|
||||||
|
self.Embark.initConfig(env || 'development', {
|
||||||
|
embarkConfig: 'embark.json'
|
||||||
|
});
|
||||||
|
self.Embark.simulator({port: options.port, host: options.host});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ var ServicesMonitor = require('./services.js');
|
||||||
var Console = require('./console.js');
|
var Console = require('./console.js');
|
||||||
var IPFS = require('./ipfs.js');
|
var IPFS = require('./ipfs.js');
|
||||||
var Swarm = require('./swarm.js');
|
var Swarm = require('./swarm.js');
|
||||||
|
var Simulator = require('./simulator.js');
|
||||||
|
|
||||||
var Embark = {
|
var Embark = {
|
||||||
|
|
||||||
|
@ -337,6 +338,11 @@ var Embark = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
simulator: function(options) {
|
||||||
|
var simulator = new Simulator({blockchainConfig: this.config.blockchainConfig});
|
||||||
|
simulator.run(options);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = Embark;
|
module.exports = Embark;
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
|
||||||
|
var Simulator = function(options) {
|
||||||
|
this.blockchainConfig = options.blockchainConfig;
|
||||||
|
};
|
||||||
|
|
||||||
|
Simulator.prototype.run = function(options) {
|
||||||
|
var cmds = [];
|
||||||
|
|
||||||
|
cmds.push("-p " + (this.blockchainConfig.rpcPort || options.port || 8545));
|
||||||
|
cmds.push("-h " + (this.blockchainConfig.rpcHost || options.host || 'localhost'));
|
||||||
|
cmds.push("-a " + (options.num || 10));
|
||||||
|
|
||||||
|
exec('testrpc ' + cmds.join(' '));
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = Simulator;
|
||||||
|
|
Loading…
Reference in New Issue