Skip to content

Commit ea16259

Browse files
committed
support embark blockchain without node modules
1 parent 1fef23a commit ea16259

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

bin/embark

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ program.command('blockchain [env]').description('run blockchain').action(functio
109109
Embark.init()
110110
Embark.blockchainConfig.loadConfigFile(embarkConfig.blockchainConfig)
111111
Embark.contractsConfig.loadConfigFile(embarkConfig.contractsConfig)
112-
Embark.startBlockchain(env);
112+
113+
//TODO: better with --exec, but need to fix console bug first
114+
wrench.copyDirSyncRecursive(__dirname + "/../js", "/tmp", {forceDelete: true});
115+
116+
Embark.startBlockchain(env, true);
113117
}
114118
});
115119

lib/blockchain.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Blockchain.prototype.init_command = function() {
4444
return this.generate_basic_command() + "account new ";
4545
}
4646

47-
Blockchain.prototype.run_command = function(address) {
47+
Blockchain.prototype.run_command = function(address, use_tmp) {
4848
var cmd = this.generate_basic_command();
4949
var config = this.config;
5050

@@ -57,7 +57,12 @@ Blockchain.prototype.run_command = function(address) {
5757
}
5858

5959
if (config.mine_when_needed) {
60-
cmd += "js node_modules/embark-framework/js/mine.js";
60+
if (use_tmp) {
61+
cmd += "js /tmp/mine.js";
62+
}
63+
else {
64+
cmd += "js node_modules/embark-framework/js/mine.js";
65+
}
6166
}
6267

6368
return cmd;
@@ -84,10 +89,10 @@ Blockchain.prototype.get_address = function() {
8489
return address;
8590
}
8691

87-
Blockchain.prototype.startChain = function() {
92+
Blockchain.prototype.startChain = function(use_tmp) {
8893
var address = this.get_address();
89-
console.log("running: " + this.run_command(address));
90-
exec(this.run_command(address));
94+
console.log("running: " + this.run_command(address, use_tmp));
95+
exec(this.run_command(address, use_tmp));
9196
}
9297

9398
module.exports = Blockchain

lib/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ Embark = {
3030
return new Tests(this.contractsConfig, contractFiles);
3131
},
3232

33-
startBlockchain: function(env) {
33+
startBlockchain: function(env, use_tmp) {
3434
var chain = new Blockchain(this.blockchainConfig.config(env));
35-
chain.startChain();
35+
chain.startChain(use_tmp);
3636
},
3737

3838
deployContracts: function(env, contractFiles, destFile) {

0 commit comments

Comments
 (0)