Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/cli-repl/src/cli-repl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,14 @@ describe('CliRepl', () => {
await cliRepl.start('', {});
expect(output).to.include('reached five');
});

it('if an exception is thrown, indicates that it comes from mongoshrc', async() => {
await fs.writeFile(path.join(tmpdir.path, '.mongoshrc.js'), 'throw new Error("bananas")');
cliRepl = new CliRepl(cliReplOptions);
await cliRepl.start('', {});
expect(output).to.include('Error while running ~/.mongoshrc.js:');
expect(output).to.include('Error: bananas');
});
});

context('files loaded from command line', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/cli-repl/src/cli-repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ class CliRepl {
this.bus.emit('mongosh:mongoshrc-load');
await this.mongoshRepl.loadExternalFile(mongoshrcPath);
} catch (err) {
this.output.write(this.clr('Error while running ~/.mongoshrc.js:\n', ['bold', 'yellow']));
this.output.write(this.mongoshRepl.writer(err) + '\n');
}
return;
Expand Down