From 774a14c85013629d825a7747cdcd9e9a94a57ae7 Mon Sep 17 00:00:00 2001 From: Anthony Laibe Date: Fri, 10 Aug 2018 15:54:21 +0100 Subject: [PATCH] Support old and new console plugin with a warning --- cmd/cmd_controller.js | 2 ++ cmd/dashboard/console.js | 9 ++++++++- cmd/dashboard/dashboard.js | 3 ++- cmd/dashboard/repl.js | 4 +++- lib/modules/webserver/index.js | 2 +- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/cmd/cmd_controller.js b/cmd/cmd_controller.js index beef7db0..143fa250 100644 --- a/cmd/cmd_controller.js +++ b/cmd/cmd_controller.js @@ -107,6 +107,7 @@ class EmbarkController { plugins: engine.plugins, version: engine.version, events: engine.events, + logger: engine.logger, ipc: engine.ipc }).startConsole(); return callback(); @@ -342,6 +343,7 @@ class EmbarkController { plugins: engine.plugins, version: engine.version, events: engine.events, + logger: engine.logger, ipc: engine.ipc }); repl.start(callback); diff --git a/cmd/dashboard/console.js b/cmd/dashboard/console.js index 2ef31d29..6496ba20 100644 --- a/cmd/dashboard/console.js +++ b/cmd/dashboard/console.js @@ -5,6 +5,7 @@ class Console { this.events = options.events; this.plugins = options.plugins; this.version = options.version; + this.logger = options.logger; this.ipc = options.ipc; if (this.ipc.isServer()) { @@ -38,7 +39,13 @@ class Console { var pluginCmds = this.plugins.getPluginsProperty('console', 'console'); for (let pluginCmd of pluginCmds) { let pluginResult = pluginCmd.call(this, cmd, {}); - if (pluginResult.match()) { + if(typeof pluginResult !== 'object'){ + if (pluginResult !== false && pluginResult !== 'false' && pluginResult !== undefined) { + this.logger.warn("[DEPRECATED] In future versions of embark, we expect the console command to return an object " + + "having 2 functions: match and process."); + return callback(null, pluginResult); + } + } else if (pluginResult.match()) { return pluginResult.process(callback); } } diff --git a/cmd/dashboard/dashboard.js b/cmd/dashboard/dashboard.js index d1727f7d..107ebb97 100644 --- a/cmd/dashboard/dashboard.js +++ b/cmd/dashboard/dashboard.js @@ -34,7 +34,8 @@ class Dashboard { events: self.events, plugins: self.plugins, version: self.version, - ipc: self.ipc + ipc: self.ipc, + logger: self.logger }); callback(); }, diff --git a/cmd/dashboard/repl.js b/cmd/dashboard/repl.js index 1951c4f1..0432943b 100644 --- a/cmd/dashboard/repl.js +++ b/cmd/dashboard/repl.js @@ -5,6 +5,7 @@ const Console = require('./console.js'); class REPL { constructor(options) { + this.logger = options.logger; this.env = options.env; this.plugins = options.plugins; this.events = options.events; @@ -17,7 +18,8 @@ class REPL { events: this.events, plugins: this.plugins, version: this.version, - ipc: this.ipc + ipc: this.ipc, + logger: this.logger }); } diff --git a/lib/modules/webserver/index.js b/lib/modules/webserver/index.js index 8c0ac7ea..cfd5d7ba 100644 --- a/lib/modules/webserver/index.js +++ b/lib/modules/webserver/index.js @@ -54,7 +54,7 @@ class WebServer { return { match: () => cmd === "webserver start", process: (callback) => self.events.request("start-webserver", callback) - } + }; }); self.embark.registerConsoleCommand((cmd, _options) => {