File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -388,6 +388,14 @@ describe('CliRepl', () => {
388
388
await cliRepl . start ( '' , { } ) ;
389
389
expect ( output ) . to . include ( 'reached five' ) ;
390
390
} ) ;
391
+
392
+ it ( 'if an exception is thrown, indicates that it comes from mongoshrc' , async ( ) => {
393
+ await fs . writeFile ( path . join ( tmpdir . path , '.mongoshrc.js' ) , 'throw new Error("bananas")' ) ;
394
+ cliRepl = new CliRepl ( cliReplOptions ) ;
395
+ await cliRepl . start ( '' , { } ) ;
396
+ expect ( output ) . to . include ( 'Error while running ~/.mongoshrc.js:' ) ;
397
+ expect ( output ) . to . include ( 'Error: bananas' ) ;
398
+ } ) ;
391
399
} ) ;
392
400
393
401
context ( 'files loaded from command line' , ( ) => {
Original file line number Diff line number Diff line change @@ -240,6 +240,7 @@ class CliRepl {
240
240
this . bus . emit ( 'mongosh:mongoshrc-load' ) ;
241
241
await this . mongoshRepl . loadExternalFile ( mongoshrcPath ) ;
242
242
} catch ( err ) {
243
+ this . output . write ( this . clr ( 'Error while running ~/.mongoshrc.js:\n' , [ 'bold' , 'yellow' ] ) ) ;
243
244
this . output . write ( this . mongoshRepl . writer ( err ) + '\n' ) ;
244
245
}
245
246
return ;
You can’t perform that action at this time.
0 commit comments