Merge pull request #401 from embark-framework/bug_fix/blockchain-dev
Use --dev when in development
This commit is contained in:
commit
f85017e3f4
|
@ -50,12 +50,26 @@ var Blockchain = function(options) {
|
|||
this.config.datadir = fs.embarkPath(".embark/development/datadir");
|
||||
}
|
||||
|
||||
this.client = new options.client({config: this.config, env: this.env});
|
||||
if (this.blockchainConfig.isDev) {
|
||||
this.isDev = true;
|
||||
} else if (this.blockchainConfig.isDev === false) {
|
||||
this.isDev = false;
|
||||
} else {
|
||||
this.isDev = this.env === 'development';
|
||||
}
|
||||
|
||||
this.client = new options.client({config: this.config, env: this.env, isDev: this.isDev});
|
||||
};
|
||||
|
||||
Blockchain.prototype.runCommand = function(cmd, options) {
|
||||
console.log(("running: " + cmd.underline).green);
|
||||
return shelljs.exec(cmd, options);
|
||||
return shelljs.exec(cmd, options, (err, stdout, _stderr) => {
|
||||
if (err && this.env === 'development' && stdout.indexOf('Failed to unlock developer account') > 0) {
|
||||
console.warn('\nDevelopment blockchain has changed to use the --dev option.'.yellow);
|
||||
console.warn('You can reset your workspace to fix the problem with'.yellow + ' embark reset'.cyan);
|
||||
console.warn('Otherwise, you can change your data directory in blockchain.json (datadir)'.yellow);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Blockchain.prototype.run = function() {
|
||||
|
@ -69,7 +83,10 @@ Blockchain.prototype.run = function() {
|
|||
console.log(("could not find " + this.config.geth_bin + " command; is " + this.client.name + " installed or in the PATH?").green);
|
||||
return;
|
||||
}
|
||||
var address = this.initChainAndGetAddress();
|
||||
let address = '';
|
||||
if (!this.isDev) {
|
||||
address = this.initChainAndGetAddress();
|
||||
}
|
||||
this.client.mainCommand(address, function(cmd) {
|
||||
self.runCommand(cmd, {async: true});
|
||||
});
|
||||
|
|
|
@ -5,6 +5,7 @@ class GethCommands {
|
|||
constructor(options) {
|
||||
this.config = options && options.hasOwnProperty('config') ? options.config : {};
|
||||
this.env = options && options.hasOwnProperty('env') ? options.env : 'development';
|
||||
this.isDev = options && options.hasOwnProperty('isDev') ? options.isDev : (this.env === 'development');
|
||||
this.name = "Go-Ethereum (https://github.com/ethereum/go-ethereum)";
|
||||
this.geth_bin = this.config.geth_bin || "geth";
|
||||
}
|
||||
|
@ -188,7 +189,7 @@ class GethCommands {
|
|||
} else {
|
||||
accountAddress = address;
|
||||
}
|
||||
if (accountAddress) {
|
||||
if (accountAddress && !self.isDev) {
|
||||
return callback(null, "--unlock=" + accountAddress);
|
||||
}
|
||||
callback(null, "");
|
||||
|
@ -200,10 +201,16 @@ class GethCommands {
|
|||
callback(null, "");
|
||||
},
|
||||
function mineWhenNeeded(callback) {
|
||||
if (config.mineWhenNeeded) {
|
||||
if (config.mineWhenNeeded && !self.isDev) {
|
||||
return callback(null, "js .embark/" + self.env + "/js/mine.js");
|
||||
}
|
||||
callback(null, "");
|
||||
},
|
||||
function isDev(callback) {
|
||||
if (self.isDev) {
|
||||
return callback(null, '--dev');
|
||||
}
|
||||
callback(null, '');
|
||||
}
|
||||
], function (err, results) {
|
||||
if (err) {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
"networkType": "custom",
|
||||
"genesisBlock": "config/development/genesis.json",
|
||||
"datadir": ".embark/development/datadir",
|
||||
"isDev": true,
|
||||
"mineWhenNeeded": true,
|
||||
"nodiscover": true,
|
||||
"maxpeers": 0,
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
"networkType": "custom",
|
||||
"genesisBlock": "config/development/genesis.json",
|
||||
"datadir": ".embark/development/datadir",
|
||||
"isDev": true,
|
||||
"mineWhenNeeded": true,
|
||||
"nodiscover": true,
|
||||
"maxpeers": 0,
|
||||
|
|
|
@ -22,6 +22,7 @@ describe('embark.Config', function () {
|
|||
"networkType": "custom",
|
||||
"genesisBlock": "config/development/genesis.json",
|
||||
"datadir": ".embark/development/datadir",
|
||||
"isDev": true,
|
||||
"mineWhenNeeded": true,
|
||||
"nodiscover": true,
|
||||
"rpcHost": "localhost",
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
"networkType": "custom",
|
||||
"genesisBlock": "config/development/genesis.json",
|
||||
"datadir": ".embark/development/datadir",
|
||||
"isDev": true,
|
||||
"mineWhenNeeded": true,
|
||||
"nodiscover": true,
|
||||
"rpcHost": "localhost",
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
"networkType": "custom",
|
||||
"genesisBlock": "development/genesis.json",
|
||||
"datadir": ".embark/development/datadir",
|
||||
"isDev": true,
|
||||
"mineWhenNeeded": true,
|
||||
"nodiscover": true,
|
||||
"maxpeers": 0,
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
"networkType": "custom",
|
||||
"genesisBlock": "config/development/genesis.json",
|
||||
"datadir": ".embark/development/datadir",
|
||||
"isDev": true,
|
||||
"mineWhenNeeded": true,
|
||||
"nodiscover": true,
|
||||
"maxpeers": 0,
|
||||
|
|
Loading…
Reference in New Issue