From 92173c99072c336305914861c0bffe774e8ac057 Mon Sep 17 00:00:00 2001 From: Gerbrand van DIeijen Date: Tue, 18 Aug 2015 12:05:20 +0200 Subject: [PATCH] Add option to run geth with any command --- bin/embark | 13 ++++++++++++- lib/blockchain.js | 10 ++++++++++ lib/index.js | 6 +++++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/bin/embark b/bin/embark index 868a4eea..9b258b11 100755 --- a/bin/embark +++ b/bin/embark @@ -139,6 +139,18 @@ program.command('blockchain [env]').description('run blockchain').action(functio } }); +program.command('geth [args...]').description('run geth with specified arguments').action(function(env_, args_) { + var env = env_ || 'development'; + var embarkConfig = readYaml.sync("./embark.yml"); + var args = args_.join(' '); + + Embark.init() + Embark.blockchainConfig.loadConfigFile(embarkConfig.blockchainConfig) + Embark.contractsConfig.loadConfigFile(embarkConfig.contractsConfig) + + Embark.geth(env, args); +}); + program.command('demo').description('create a working dapp with a SimpleStorage contract').action(function() { var boilerPath = path.join(__dirname + '/../boilerplate'); var demoPath = path.join(__dirname + '/../demo'); @@ -169,4 +181,3 @@ if (!process.argv.slice(2).length) { } exit(); - diff --git a/lib/blockchain.js b/lib/blockchain.js index 4afd8d4d..45c8bd9e 100644 --- a/lib/blockchain.js +++ b/lib/blockchain.js @@ -57,6 +57,10 @@ Blockchain.prototype.init_command = function() { return this.generate_basic_command() + "account new "; } +Blockchain.prototype.geth_command = function(geth_args) { + return this.generate_basic_command() + geth_args; +} + Blockchain.prototype.run_command = function(address, use_tmp) { var cmd = this.generate_basic_command(); var config = this.config; @@ -116,4 +120,10 @@ Blockchain.prototype.startChain = function(use_tmp) { exec(this.run_command(address, use_tmp)); } +Blockchain.prototype.execGeth = function(args) { + var cmd = this.geth_command(args); + console.log("executing: " + cmd); + exec(cmd); +} + module.exports = Blockchain diff --git a/lib/index.js b/lib/index.js index 95618130..e81dcc4b 100644 --- a/lib/index.js +++ b/lib/index.js @@ -44,8 +44,12 @@ Embark = { return deploy.generate_abi_file(destFile); }, + geth: function(env, args) { + var chain = new Blockchain(this.blockchainConfig.config(env)); + chain.execGeth(args); + }, + release: Release } module.exports = Embark; -