@@ -51,13 +51,16 @@ var Server = function (cliOptions, done) {
5151
5252 this . log = logger . create ( )
5353
54+ this . loadErrors = [ ]
55+
5456 var config = cfg . parseConfig ( cliOptions . configFile , cliOptions )
5557
5658 var modules = [ {
5759 helper : [ 'value' , helper ] ,
5860 logger : [ 'value' , logger ] ,
5961 done : [ 'value' , done || process . exit ] ,
6062 emitter : [ 'value' , this ] ,
63+ server : [ 'value' , this ] ,
6164 launcher : [ 'type' , Launcher ] ,
6265 config : [ 'value' , config ] ,
6366 preprocess : [ 'factory' , preprocessor . createPreprocessor ] ,
@@ -82,8 +85,9 @@ var Server = function (cliOptions, done) {
8285 } ]
8386 } ]
8487
88+ this . _setUpLoadErrorListener ( )
8589 // Load the plugins
86- modules = modules . concat ( plugin . resolve ( config . plugins ) )
90+ modules = modules . concat ( plugin . resolve ( config . plugins , this ) )
8791
8892 this . _injector = new di . Injector ( modules )
8993}
@@ -169,12 +173,16 @@ Server.prototype._start = function (config, launcher, preprocess, fileList, webS
169173 config . protocol , config . hostname , config . port , config . urlRoot )
170174
171175 self . emit ( 'listening' , config . port )
172-
173176 if ( config . browsers && config . browsers . length ) {
174177 self . _injector . invoke ( launcher . launch , launcher ) . forEach ( function ( browserLauncher ) {
175178 singleRunDoneBrowsers [ browserLauncher . id ] = false
176179 } )
177180 }
181+ var noLoadErrors = self . loadErrors . length
182+ if ( noLoadErrors > 0 ) {
183+ self . log . error ( 'Found %d load error%s' , noLoadErrors , noLoadErrors === 1 ? '' : 's' )
184+ process . kill ( process . pid , 'SIGINT' )
185+ }
178186 } )
179187 }
180188
@@ -363,6 +371,14 @@ Server.prototype._start = function (config, launcher, preprocess, fileList, webS
363371 } )
364372}
365373
374+ Server . prototype . _setUpLoadErrorListener = function ( ) {
375+ var self = this
376+ self . on ( 'load_error' , function ( type , name ) {
377+ self . log . debug ( 'Registered a load error of type %s with name %s' , type , name )
378+ self . loadErrors . push ( [ type , name ] )
379+ } )
380+ }
381+
366382Server . prototype . _detach = function ( config , done ) {
367383 var log = this . log
368384 var tmpFile = tmp . fileSync ( { keep : true } )
0 commit comments