fix(@embark/cli): start the dashboard after services are started

Start the `embark run` dashboard after services have been started so the REPL
instantiated by the dashboard can successfully request the `console:history`
event.

Delete `cmd/dashboard/command_history.js` since it's no longer in use.
This commit is contained in:
Michael Bradley, Jr 2018-12-19 18:04:08 -06:00 committed by Iuri Matias
parent e3a7b74284
commit 6c7782c435
2 changed files with 18 additions and 60 deletions

View File

@ -108,23 +108,6 @@ class EmbarkController {
callback();
});
},
function startDashboard(callback) {
if (!options.useDashboard) {
return callback();
}
let dashboard = new Dashboard({
events: engine.events,
logger: engine.logger,
plugins: engine.plugins,
version: self.version,
env: engine.env
});
dashboard.start(function () {
engine.logger.info(__('dashboard start'));
callback();
});
},
function (callback) {
let pluginList = engine.plugins.listPlugins();
if (pluginList.length > 0) {
@ -168,6 +151,24 @@ class EmbarkController {
}
engine.startService("fileWatcher");
callback();
},
function startDashboard(callback) {
if (!options.useDashboard) {
return callback();
}
let dashboard = new Dashboard({
events: engine.events,
logger: engine.logger,
plugins: engine.plugins,
version: self.version,
env: engine.env,
ipc: engine.ipc
});
dashboard.start(function () {
engine.logger.info(__('dashboard start'));
callback();
});
}
], function (err, _result) {
if (err) {

View File

@ -1,43 +0,0 @@
let fs = require('../../lib/core/fs');
class CommandHistory {
constructor(options = {}) {
this.cmdHistoryFile = options.cmdHistoryFile || fs.dappPath('.embark', 'cmd_history');
this.history = [];
this.pointer = -1;
this.loadHistory();
}
addCommand(cmd) {
this.history.push(cmd);
this.pointer = this.history.length;
}
getPreviousCommand() {
if (this.pointer >= 0) {
this.pointer--;
}
return this.history[this.pointer];
}
getNextCommand() {
if (this.pointer >= this.history.length) {
this.pointer = this.history.length - 1;
return '';
}
this.pointer++;
return this.history[this.pointer];
}
loadHistory() {
if (fs.existsSync(this.cmdHistoryFile)) {
fs.readFileSync(this.cmdHistoryFile)
.toString()
.split('\n')
.reverse()
.forEach((cmd) => { this.addCommand(cmd); })
}
}
}
module.exports = CommandHistory;