mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-12 06:44:37 +00:00
use specified environment when creating data dirs for .embark
This commit is contained in:
parent
1a436dcc12
commit
a9e4435b77
@ -5,8 +5,9 @@ var fs = require('../../core/fs.js');
|
|||||||
|
|
||||||
var GethCommands = require('./geth_commands.js');
|
var GethCommands = require('./geth_commands.js');
|
||||||
|
|
||||||
var Blockchain = function(blockchainConfig, Client) {
|
var Blockchain = function(blockchainConfig, Client, env) {
|
||||||
this.blockchainConfig = blockchainConfig;
|
this.blockchainConfig = blockchainConfig;
|
||||||
|
this.env = env || 'development';
|
||||||
|
|
||||||
this.config = {
|
this.config = {
|
||||||
geth_bin: this.blockchainConfig.geth_bin || 'geth',
|
geth_bin: this.blockchainConfig.geth_bin || 'geth',
|
||||||
@ -29,7 +30,7 @@ var Blockchain = function(blockchainConfig, Client) {
|
|||||||
vmdebug: this.blockchainConfig.vmdebug || false
|
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) {
|
Blockchain.prototype.runCommand = function(cmd) {
|
||||||
@ -52,11 +53,11 @@ Blockchain.prototype.initChainAndGetAddress = function() {
|
|||||||
var address = null, result;
|
var address = null, result;
|
||||||
|
|
||||||
// ensure datadir exists, bypassing the interactive liabilities prompt.
|
// ensure datadir exists, bypassing the interactive liabilities prompt.
|
||||||
this.datadir = '.embark/development/datadir';
|
this.datadir = '.embark/' + this.env + '/datadir';
|
||||||
fs.mkdirpSync(this.datadir);
|
fs.mkdirpSync(this.datadir);
|
||||||
|
|
||||||
// copy mining script
|
// 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
|
// check if an account already exists, create one if not, return address
|
||||||
result = this.runCommand(this.client.listAccountsCommand());
|
result = this.runCommand(this.client.listAccountsCommand());
|
||||||
@ -77,9 +78,9 @@ Blockchain.prototype.initChainAndGetAddress = function() {
|
|||||||
return address;
|
return address;
|
||||||
};
|
};
|
||||||
|
|
||||||
var BlockchainClient = function(blockchainConfig, client) {
|
var BlockchainClient = function(blockchainConfig, client, env) {
|
||||||
if (client === 'geth') {
|
if (client === 'geth') {
|
||||||
return new Blockchain(blockchainConfig, GethCommands);
|
return new Blockchain(blockchainConfig, GethCommands, env);
|
||||||
} else {
|
} else {
|
||||||
throw new Error('unknown client');
|
throw new Error('unknown client');
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
var GethCommands = function(options) {
|
var GethCommands = function(options) {
|
||||||
this.config = options.config;
|
this.config = options.config;
|
||||||
|
this.env = options.env || 'development';
|
||||||
this.name = "Go-Ethereum (https://github.com/ethereum/go-ethereum)";
|
this.name = "Go-Ethereum (https://github.com/ethereum/go-ethereum)";
|
||||||
this.geth_bin = this.config.geth_bin || "geth";
|
this.geth_bin = this.config.geth_bin || "geth";
|
||||||
};
|
};
|
||||||
@ -110,7 +111,7 @@ GethCommands.prototype.mainCommand = function(address) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (config.mineWhenNeeded) {
|
if (config.mineWhenNeeded) {
|
||||||
cmd += "js .embark/development/js/mine.js";
|
cmd += "js .embark/" + this.env + "/js/mine.js";
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd;
|
return cmd;
|
||||||
|
@ -47,8 +47,8 @@ var Embark = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
blockchain: function(env, client) {
|
blockchain: function(env, client) {
|
||||||
var blockchain = Blockchain(this.config.blockchainConfig, client);
|
var blockchain = Blockchain(this.config.blockchainConfig, client, env);
|
||||||
blockchain.run({env: env});
|
blockchain.run();
|
||||||
},
|
},
|
||||||
|
|
||||||
simulator: function(options) {
|
simulator: function(options) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user