use specified environment when creating data dirs for .embark

This commit is contained in:
Iuri Matias 2017-02-20 16:11:27 -05:00
parent 1a436dcc12
commit a9e4435b77
3 changed files with 11 additions and 9 deletions

View File

@ -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');
}

View File

@ -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;

View File

@ -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) {