use --dev when in development

This commit is contained in:
Jonathan Rainville 2018-05-08 16:25:48 -04:00 committed by Iuri Matias
parent a0f7a6bb81
commit cffb0b334e
2 changed files with 19 additions and 4 deletions

View File

@ -55,7 +55,12 @@ var Blockchain = function(options) {
Blockchain.prototype.runCommand = function(cmd, options) { Blockchain.prototype.runCommand = function(cmd, options) {
console.log(("running: " + cmd.underline).green); 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 changed to use the --dev option.'.yellow);
console.warn('You will need to change your data directory in blockchain.json (datadir)'.yellow);
}
});
}; };
Blockchain.prototype.run = function() { Blockchain.prototype.run = function() {
@ -69,7 +74,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); console.log(("could not find " + this.config.geth_bin + " command; is " + this.client.name + " installed or in the PATH?").green);
return; return;
} }
var address = this.initChainAndGetAddress(); let address = '';
if (self.env !== "development") {
address = this.initChainAndGetAddress();
}
this.client.mainCommand(address, function(cmd) { this.client.mainCommand(address, function(cmd) {
self.runCommand(cmd, {async: true}); self.runCommand(cmd, {async: true});
}); });

View File

@ -123,6 +123,7 @@ class GethCommands {
let config = this.config; let config = this.config;
let rpc_api = (this.config.rpcApi || ['eth', 'web3', 'net']); let rpc_api = (this.config.rpcApi || ['eth', 'web3', 'net']);
let ws_api = (this.config.wsApi || ['eth', 'web3', 'net']); let ws_api = (this.config.wsApi || ['eth', 'web3', 'net']);
const isDev = self.env === 'development';
async.series([ async.series([
function commonOptions(callback) { function commonOptions(callback) {
@ -188,7 +189,7 @@ class GethCommands {
} else { } else {
accountAddress = address; accountAddress = address;
} }
if (accountAddress) { if (accountAddress && !isDev) {
return callback(null, "--unlock=" + accountAddress); return callback(null, "--unlock=" + accountAddress);
} }
callback(null, ""); callback(null, "");
@ -200,10 +201,16 @@ class GethCommands {
callback(null, ""); callback(null, "");
}, },
function mineWhenNeeded(callback) { function mineWhenNeeded(callback) {
if (config.mineWhenNeeded) { if (config.mineWhenNeeded && !isDev) {
return callback(null, "js .embark/" + self.env + "/js/mine.js"); return callback(null, "js .embark/" + self.env + "/js/mine.js");
} }
callback(null, ""); callback(null, "");
},
function isDev(callback) {
if (isDev) {
return callback(null, '--dev');
}
callback(null, '');
} }
], function (err, results) { ], function (err, results) {
if (err) { if (err) {