@@ -403,42 +403,53 @@ export class MongoInstance extends EventEmitter {
403403 this . debug ( `STDOUT: ""${ line } ""` ) ; // denoting the STDOUT string with double quotes, because the stdout might also use quotes
404404 this . emit ( MongoInstanceEvents . instanceSTDOUT , line ) ;
405405
406+ // dont use "else if", because input can be multiple lines and match multiple things
406407 if ( / w a i t i n g f o r c o n n e c t i o n s / i. test ( line ) ) {
407408 this . emit ( MongoInstanceEvents . instanceReady ) ;
408- } else if ( / a d d r e s s a l r e a d y i n u s e / i. test ( line ) ) {
409+ }
410+ if ( / a d d r e s s a l r e a d y i n u s e / i. test ( line ) ) {
409411 this . emit ( MongoInstanceEvents . instanceError , `Port ${ this . instanceOpts . port } already in use` ) ;
410- } else if ( / m o n g o d i n s t a n c e a l r e a d y r u n n i n g / i. test ( line ) ) {
412+ }
413+ if ( / m o n g o d i n s t a n c e a l r e a d y r u n n i n g / i. test ( line ) ) {
411414 this . emit ( MongoInstanceEvents . instanceError , 'Mongod already running' ) ;
412- } else if ( / p e r m i s s i o n d e n i e d / i. test ( line ) ) {
415+ }
416+ if ( / p e r m i s s i o n d e n i e d / i. test ( line ) ) {
413417 this . emit ( MongoInstanceEvents . instanceError , 'Mongod permission denied' ) ;
414- } else if ( / D a t a d i r e c t o r y .* ? n o t f o u n d / i. test ( line ) ) {
418+ }
419+ if ( / D a t a d i r e c t o r y .* ? n o t f o u n d / i. test ( line ) ) {
415420 this . emit ( MongoInstanceEvents . instanceError , 'Data directory not found' ) ;
416- } else if ( / C U R L _ O P E N S S L _ 3 .* n o t f o u n d / i. test ( line ) ) {
421+ }
422+ if ( / C U R L _ O P E N S S L _ 3 .* n o t f o u n d / i. test ( line ) ) {
417423 this . emit (
418424 MongoInstanceEvents . instanceError ,
419425 'libcurl3 is not available on your system. Mongod requires it and cannot be started without it.\n' +
420426 'You should manually install libcurl3 or try to use an newer version of MongoDB\n'
421427 ) ;
422- } else if ( / C U R L _ O P E N S S L _ 4 .* n o t f o u n d / i. test ( line ) ) {
428+ }
429+ if ( / C U R L _ O P E N S S L _ 4 .* n o t f o u n d / i. test ( line ) ) {
423430 this . emit (
424431 MongoInstanceEvents . instanceError ,
425432 'libcurl4 is not available on your system. Mongod requires it and cannot be started without it.\n' +
426433 'You need to manually install libcurl4\n'
427434 ) ;
428- } else if ( / l i b .* : c a n n o t o p e n s h a r e d o b j e c t / i. test ( line ) ) {
435+ }
436+ if ( / l i b .* : c a n n o t o p e n s h a r e d o b j e c t / i. test ( line ) ) {
429437 const lib =
430438 line . match ( / ( l i b .* ) : c a n n o t o p e n s h a r e d o b j e c t / i) ?. [ 1 ] . toLocaleLowerCase ( ) ?? 'unknown' ;
431439 this . emit (
432440 MongoInstanceEvents . instanceError ,
433441 `Instance Failed to start because an library file is missing: "${ lib } "`
434442 ) ;
435- } else if ( / \* \* \* a b o r t i n g a f t e r / i. test ( line ) ) {
443+ }
444+ if ( / \* \* \* a b o r t i n g a f t e r / i. test ( line ) ) {
436445 this . emit ( MongoInstanceEvents . instanceError , 'Mongod internal error' ) ;
437- } else if ( / t r a n s i t i o n t o p r i m a r y c o m p l e t e ; d a t a b a s e w r i t e s a r e n o w p e r m i t t e d / i. test ( line ) ) {
446+ }
447+ if ( / t r a n s i t i o n t o p r i m a r y c o m p l e t e ; d a t a b a s e w r i t e s a r e n o w p e r m i t t e d / i. test ( line ) ) {
438448 this . isInstancePrimary = true ;
439449 this . debug ( 'Calling all waitForPrimary resolve functions' ) ;
440450 this . emit ( MongoInstanceEvents . instancePrimary ) ;
441- } else if ( / m e m b e r [ \d \. : ] + i s n o w i n s t a t e \w + / i. test ( line ) ) {
451+ }
452+ if ( / m e m b e r [ \d \. : ] + i s n o w i n s t a t e \w + / i. test ( line ) ) {
442453 // "[\d\.:]+" matches "0.0.0.0:0000" (IP:PORT)
443454 const state = / m e m b e r [ \d \. : ] + i s n o w i n s t a t e ( \w + ) / i. exec ( line ) ?. [ 1 ] ?? 'UNKNOWN' ;
444455 this . emit ( MongoInstanceEvents . instanceReplState , state ) ;
0 commit comments