mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-24 11:28:46 +00:00
only log loaded plugins in list plugins and warn when plugin is not right
This commit is contained in:
parent
51c2c8f880
commit
97e91d4c44
@ -235,7 +235,6 @@ class Engine {
|
|||||||
self.context = constants.contexts.simulator;
|
self.context = constants.contexts.simulator;
|
||||||
}
|
}
|
||||||
if (oldContext !== self.context) {
|
if (oldContext !== self.context) {
|
||||||
console.log('Emiting context change');
|
|
||||||
self.events.emit(constants.events.contextChange, self.context);
|
self.events.emit(constants.events.contextChange, self.context);
|
||||||
}
|
}
|
||||||
let versionNumber = version.split("/")[1].split("-")[0];
|
let versionNumber = version.split("/")[1].split("-")[0];
|
||||||
|
@ -28,14 +28,19 @@ var Plugin = function(options) {
|
|||||||
this.logger = options.logger;
|
this.logger = options.logger;
|
||||||
this.events = options.events;
|
this.events = options.events;
|
||||||
this.config = options.config;
|
this.config = options.config;
|
||||||
|
this.loaded = false;
|
||||||
this.context = options.pluginConfig.context || constants.contexts.any;
|
this.context = options.pluginConfig.context || constants.contexts.any;
|
||||||
};
|
};
|
||||||
|
|
||||||
Plugin.prototype.loadPlugin = function(currentContext) {
|
Plugin.prototype.loadPlugin = function(currentContext) {
|
||||||
if (this.context !== constants.contexts.any && this.context !== currentContext) {
|
if (this.context !== constants.contexts.any && this.context !== currentContext) {
|
||||||
this.events.on(constants.events.contextChange, this.loadPlugin.bind(this));
|
if (currentContext) {
|
||||||
return;
|
this.logger.warn(`Plugin ${this.name} can only be loaded in the context of the ${this.context}`);
|
||||||
}
|
}
|
||||||
|
return this.events.on(constants.events.contextChange, this.loadPlugin.bind(this));
|
||||||
|
}
|
||||||
|
this.loaded = true;
|
||||||
|
this.logger.info(`Loaded plugin ${this.name}`);
|
||||||
this.events.removeListener(constants.events.contextChange, this.loadPlugin.bind(this));
|
this.events.removeListener(constants.events.contextChange, this.loadPlugin.bind(this));
|
||||||
if (this.shouldInterceptLogs) {
|
if (this.shouldInterceptLogs) {
|
||||||
this.interceptLogs(this.pluginModule);
|
this.interceptLogs(this.pluginModule);
|
||||||
|
@ -20,10 +20,12 @@ Plugins.prototype.loadPlugins = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Plugins.prototype.listPlugins = function() {
|
Plugins.prototype.listPlugins = function() {
|
||||||
var list = [];
|
const list = [];
|
||||||
for (var className in this.pluginList) {
|
this.plugins.forEach(plugin => {
|
||||||
list.push(className);
|
if (plugin.loaded) {
|
||||||
|
list.push(plugin.name);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
return list;
|
return list;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user