File tree Expand file tree Collapse file tree 3 files changed +13
-7
lines changed Expand file tree Collapse file tree 3 files changed +13
-7
lines changed Original file line number Diff line number Diff 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 ] ;
Original file line number Diff line number Diff 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
3435Plugin . 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 ) ;
Original file line number Diff line number Diff line change @@ -20,10 +20,12 @@ Plugins.prototype.loadPlugins = function() {
2020} ;
2121
2222Plugins . 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
You can’t perform that action at this time.
0 commit comments