From ea16259f342554c1038ef2b5c95bea5c00529c38 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sun, 12 Jul 2015 21:33:36 -0400 Subject: [PATCH] support embark blockchain without node modules --- bin/embark | 6 +++++- lib/blockchain.js | 15 ++++++++++----- lib/index.js | 4 ++-- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/bin/embark b/bin/embark index f6da6e18e..f8737d163 100644 --- a/bin/embark +++ b/bin/embark @@ -109,7 +109,11 @@ program.command('blockchain [env]').description('run blockchain').action(functio Embark.init() Embark.blockchainConfig.loadConfigFile(embarkConfig.blockchainConfig) Embark.contractsConfig.loadConfigFile(embarkConfig.contractsConfig) - Embark.startBlockchain(env); + + //TODO: better with --exec, but need to fix console bug first + wrench.copyDirSyncRecursive(__dirname + "/../js", "/tmp", {forceDelete: true}); + + Embark.startBlockchain(env, true); } }); diff --git a/lib/blockchain.js b/lib/blockchain.js index d10805f7e..fc7cc9ceb 100644 --- a/lib/blockchain.js +++ b/lib/blockchain.js @@ -44,7 +44,7 @@ Blockchain.prototype.init_command = function() { return this.generate_basic_command() + "account new "; } -Blockchain.prototype.run_command = function(address) { +Blockchain.prototype.run_command = function(address, use_tmp) { var cmd = this.generate_basic_command(); var config = this.config; @@ -57,7 +57,12 @@ Blockchain.prototype.run_command = function(address) { } if (config.mine_when_needed) { - cmd += "js node_modules/embark-framework/js/mine.js"; + if (use_tmp) { + cmd += "js /tmp/mine.js"; + } + else { + cmd += "js node_modules/embark-framework/js/mine.js"; + } } return cmd; @@ -84,10 +89,10 @@ Blockchain.prototype.get_address = function() { return address; } -Blockchain.prototype.startChain = function() { +Blockchain.prototype.startChain = function(use_tmp) { var address = this.get_address(); - console.log("running: " + this.run_command(address)); - exec(this.run_command(address)); + console.log("running: " + this.run_command(address, use_tmp)); + exec(this.run_command(address, use_tmp)); } module.exports = Blockchain diff --git a/lib/index.js b/lib/index.js index b168f00d0..8281b4ef6 100644 --- a/lib/index.js +++ b/lib/index.js @@ -30,9 +30,9 @@ Embark = { return new Tests(this.contractsConfig, contractFiles); }, - startBlockchain: function(env) { + startBlockchain: function(env, use_tmp) { var chain = new Blockchain(this.blockchainConfig.config(env)); - chain.startChain(); + chain.startChain(use_tmp); }, deployContracts: function(env, contractFiles, destFile) {