Support old and new console plugin with a warning
This commit is contained in:
parent
f2939ae91b
commit
774a14c850
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
},
|
||||
|
|
|
@ -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
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ class WebServer {
|
|||
return {
|
||||
match: () => cmd === "webserver start",
|
||||
process: (callback) => self.events.request("start-webserver", callback)
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
self.embark.registerConsoleCommand((cmd, _options) => {
|
||||
|
|
Loading…
Reference in New Issue