Skip to content

Commit

Permalink
Prevent crash when ProgramBuilder.run called with no options (#1316)
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron authored Oct 2, 2024
1 parent 3a2dc72 commit 16b1f30
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/ProgramBuilder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ describe('ProgramBuilder', () => {
});

describe('run', () => {
it('does not crash when options is undefined', async () => {
sinon.stub(builder as any, 'runOnce').callsFake(() => { });
await builder.run(undefined as any);
});

it('uses default options when the config file fails to parse', async () => {
//supress the console log statements for the bsconfig parse errors
sinon.stub(console, 'log').returns(undefined);
Expand Down
4 changes: 3 additions & 1 deletion src/ProgramBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ export class ProgramBuilder {
}

public async run(options: BsConfig) {
this.logger.logLevel = options.logLevel;
if (options?.logLevel) {
this.logger.logLevel = options.logLevel;
}

if (this.isRunning) {
throw new Error('Server is already running');
Expand Down

0 comments on commit 16b1f30

Please sign in to comment.