support embark blockchain without node modules

This commit is contained in:
Iuri Matias 2015-07-12 21:33:36 -04:00
parent 1fef23a14c
commit ea16259f34
3 changed files with 17 additions and 8 deletions

View File

@ -109,7 +109,11 @@ program.command('blockchain [env]').description('run blockchain').action(functio
Embark.init() Embark.init()
Embark.blockchainConfig.loadConfigFile(embarkConfig.blockchainConfig) Embark.blockchainConfig.loadConfigFile(embarkConfig.blockchainConfig)
Embark.contractsConfig.loadConfigFile(embarkConfig.contractsConfig) 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);
} }
}); });

View File

@ -44,7 +44,7 @@ Blockchain.prototype.init_command = function() {
return this.generate_basic_command() + "account new "; 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 cmd = this.generate_basic_command();
var config = this.config; var config = this.config;
@ -57,8 +57,13 @@ Blockchain.prototype.run_command = function(address) {
} }
if (config.mine_when_needed) { if (config.mine_when_needed) {
if (use_tmp) {
cmd += "js /tmp/mine.js";
}
else {
cmd += "js node_modules/embark-framework/js/mine.js"; cmd += "js node_modules/embark-framework/js/mine.js";
} }
}
return cmd; return cmd;
} }
@ -84,10 +89,10 @@ Blockchain.prototype.get_address = function() {
return address; return address;
} }
Blockchain.prototype.startChain = function() { Blockchain.prototype.startChain = function(use_tmp) {
var address = this.get_address(); var address = this.get_address();
console.log("running: " + this.run_command(address)); console.log("running: " + this.run_command(address, use_tmp));
exec(this.run_command(address)); exec(this.run_command(address, use_tmp));
} }
module.exports = Blockchain module.exports = Blockchain

View File

@ -30,9 +30,9 @@ Embark = {
return new Tests(this.contractsConfig, contractFiles); return new Tests(this.contractsConfig, contractFiles);
}, },
startBlockchain: function(env) { startBlockchain: function(env, use_tmp) {
var chain = new Blockchain(this.blockchainConfig.config(env)); var chain = new Blockchain(this.blockchainConfig.config(env));
chain.startChain(); chain.startChain(use_tmp);
}, },
deployContracts: function(env, contractFiles, destFile) { deployContracts: function(env, contractFiles, destFile) {