From 6c7782c435304803745b180467fecf073934d19a Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Wed, 19 Dec 2018 18:04:08 -0600 Subject: [PATCH] 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. --- src/cmd/cmd_controller.js | 35 +++++++++++----------- src/cmd/dashboard/command_history.js | 43 ---------------------------- 2 files changed, 18 insertions(+), 60 deletions(-) delete mode 100644 src/cmd/dashboard/command_history.js diff --git a/src/cmd/cmd_controller.js b/src/cmd/cmd_controller.js index 73c3428b2..b506e51b8 100644 --- a/src/cmd/cmd_controller.js +++ b/src/cmd/cmd_controller.js @@ -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) { diff --git a/src/cmd/dashboard/command_history.js b/src/cmd/dashboard/command_history.js deleted file mode 100644 index 99a249471..000000000 --- a/src/cmd/dashboard/command_history.js +++ /dev/null @@ -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;