Skip to content

Commit 836bcfd

Browse files
authored
fix: handle missing execConfigs option (#319)
1 parent ec0111c commit 836bcfd

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/games/services/server-configurator.service.spec.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class QueueConfigServiceStub {
2929
configs: {
3030
'5cp': 'etf2l_6v6_5cp',
3131
},
32-
execConfigs: [ 'test' ],
3332
} as Partial<QueueConfig>;
3433
}
3534

@@ -106,7 +105,6 @@ describe('ServerConfiguratorService', () => {
106105
expect(spy).toHaveBeenCalledWith(kickAll());
107106
expect(spy).toHaveBeenCalledWith(changelevel('cp_badlands'));
108107
expect(spy).toHaveBeenCalledWith(execConfig('etf2l_6v6_5cp'));
109-
expect(spy).toHaveBeenCalledWith(execConfig('test'));
110108
expect(spy).toHaveBeenCalledWith(jasmine.stringMatching(/^sv_password\s.+$/));
111109
expect(spy).toHaveBeenCalledWith(addGamePlayer('PLAYER_1_STEAMID', 'PLAYER_1_NAME', 2, 'soldier'));
112110
expect(spy).toHaveBeenCalledWith(addGamePlayer('PLAYER_2_STEAMID', 'PLAYER_2_NAME', 3, 'soldier'));
@@ -127,6 +125,18 @@ describe('ServerConfiguratorService', () => {
127125
});
128126
});
129127

128+
describe('when the execConfigs is set', () => {
129+
beforeEach(() => {
130+
queueConfigService.queueConfig.execConfigs = [ 'test' ];
131+
});
132+
133+
it('should execute the configs', async () => {
134+
const spy = jest.spyOn(rcon, 'send');
135+
await service.configureServer(gameServer as any, game as any);
136+
expect(spy).toHaveBeenCalledWith(execConfig('test'));
137+
});
138+
});
139+
130140
it('should close the rcon connection', async () => {
131141
const spy = jest.spyOn(rcon, 'end');
132142
await service.configureServer(gameServer as any, game as any);

src/games/services/server-configurator.service.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ export class ServerConfiguratorService {
4848
await rcon.send(execConfig(config));
4949
}
5050

51-
for (const c of this.queueConfigService.queueConfig.execConfigs) {
52-
this.logger.debug(`[${server.name}] executing ${c}...`);
53-
await rcon.send(execConfig(c));
51+
if (this.queueConfigService.queueConfig.execConfigs) {
52+
for (const c of this.queueConfigService.queueConfig.execConfigs) {
53+
this.logger.debug(`[${server.name}] executing ${c}...`);
54+
await rcon.send(execConfig(c));
55+
}
5456
}
5557

5658
if (this.queueConfigService.queueConfig.whitelistId) {

0 commit comments

Comments
 (0)