diff --git a/lib/cmds/blockchain/blockchain.js b/lib/cmds/blockchain/blockchain.js index 275e061fd..024802029 100644 --- a/lib/cmds/blockchain/blockchain.js +++ b/lib/cmds/blockchain/blockchain.js @@ -5,8 +5,9 @@ var fs = require('../../core/fs.js'); var GethCommands = require('./geth_commands.js'); -var Blockchain = function(blockchainConfig, Client) { +var Blockchain = function(blockchainConfig, Client, env) { this.blockchainConfig = blockchainConfig; + this.env = env || 'development'; this.config = { geth_bin: this.blockchainConfig.geth_bin || 'geth', @@ -29,7 +30,7 @@ var Blockchain = function(blockchainConfig, Client) { vmdebug: this.blockchainConfig.vmdebug || false }; - this.client = new Client({config: this.config}); + this.client = new Client({config: this.config, env: this.env}); }; Blockchain.prototype.runCommand = function(cmd) { @@ -52,11 +53,11 @@ Blockchain.prototype.initChainAndGetAddress = function() { var address = null, result; // ensure datadir exists, bypassing the interactive liabilities prompt. - this.datadir = '.embark/development/datadir'; + this.datadir = '.embark/' + this.env + '/datadir'; fs.mkdirpSync(this.datadir); // copy mining script - fs.copySync(fs.embarkPath("js"), ".embark/development/js", {overwrite: true}); + fs.copySync(fs.embarkPath("js"), ".embark/" + this.env + "/js", {overwrite: true}); // check if an account already exists, create one if not, return address result = this.runCommand(this.client.listAccountsCommand()); @@ -77,9 +78,9 @@ Blockchain.prototype.initChainAndGetAddress = function() { return address; }; -var BlockchainClient = function(blockchainConfig, client) { +var BlockchainClient = function(blockchainConfig, client, env) { if (client === 'geth') { - return new Blockchain(blockchainConfig, GethCommands); + return new Blockchain(blockchainConfig, GethCommands, env); } else { throw new Error('unknown client'); } diff --git a/lib/cmds/blockchain/geth_commands.js b/lib/cmds/blockchain/geth_commands.js index bd3445c3d..83baa7636 100644 --- a/lib/cmds/blockchain/geth_commands.js +++ b/lib/cmds/blockchain/geth_commands.js @@ -1,6 +1,7 @@ var GethCommands = function(options) { this.config = options.config; + this.env = options.env || 'development'; this.name = "Go-Ethereum (https://github.com/ethereum/go-ethereum)"; this.geth_bin = this.config.geth_bin || "geth"; }; @@ -110,7 +111,7 @@ GethCommands.prototype.mainCommand = function(address) { } if (config.mineWhenNeeded) { - cmd += "js .embark/development/js/mine.js"; + cmd += "js .embark/" + this.env + "/js/mine.js"; } return cmd; diff --git a/lib/index.js b/lib/index.js index 4d3f12ff7..81c8bfea0 100644 --- a/lib/index.js +++ b/lib/index.js @@ -47,8 +47,8 @@ var Embark = { }, blockchain: function(env, client) { - var blockchain = Blockchain(this.config.blockchainConfig, client); - blockchain.run({env: env}); + var blockchain = Blockchain(this.config.blockchainConfig, client, env); + blockchain.run(); }, simulator: function(options) {