Skip to content

Commit 97e91d4

Browse files
committed
only log loaded plugins in list plugins and warn when plugin is not right
1 parent 51c2c8f commit 97e91d4

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

lib/core/engine.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ class Engine {
235235
self.context = constants.contexts.simulator;
236236
}
237237
if (oldContext !== self.context) {
238-
console.log('Emiting context change');
239238
self.events.emit(constants.events.contextChange, self.context);
240239
}
241240
let versionNumber = version.split("/")[1].split("-")[0];

lib/core/plugin.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,19 @@ var Plugin = function(options) {
2828
this.logger = options.logger;
2929
this.events = options.events;
3030
this.config = options.config;
31+
this.loaded = false;
3132
this.context = options.pluginConfig.context || constants.contexts.any;
3233
};
3334

3435
Plugin.prototype.loadPlugin = function(currentContext) {
3536
if (this.context !== constants.contexts.any && this.context !== currentContext) {
36-
this.events.on(constants.events.contextChange, this.loadPlugin.bind(this));
37-
return;
37+
if (currentContext) {
38+
this.logger.warn(`Plugin ${this.name} can only be loaded in the context of the ${this.context}`);
39+
}
40+
return this.events.on(constants.events.contextChange, this.loadPlugin.bind(this));
3841
}
42+
this.loaded = true;
43+
this.logger.info(`Loaded plugin ${this.name}`);
3944
this.events.removeListener(constants.events.contextChange, this.loadPlugin.bind(this));
4045
if (this.shouldInterceptLogs) {
4146
this.interceptLogs(this.pluginModule);

lib/core/plugins.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ Plugins.prototype.loadPlugins = function() {
2020
};
2121

2222
Plugins.prototype.listPlugins = function() {
23-
var list = [];
24-
for (var className in this.pluginList) {
25-
list.push(className);
26-
}
23+
const list = [];
24+
this.plugins.forEach(plugin => {
25+
if (plugin.loaded) {
26+
list.push(plugin.name);
27+
}
28+
});
2729
return list;
2830
};
2931

0 commit comments

Comments
 (0)