Skip to content

Commit 74ae5a7

Browse files
committed
Start mock server on startup
The mock server wasn't being started when the extension was activated when the config setting was already set.
1 parent 302722b commit 74ae5a7

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

extensions/ql-vscode/src/mocks/mock-gh-api-server.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,17 @@ export class MockGitHubApiServer extends DisposableObject {
157157
}
158158

159159
private setupConfigListener(): void {
160-
this.config.onDidChangeConfiguration(() => {
161-
if (this.config.mockServerEnabled && !this.isListening) {
162-
this.startServer();
163-
} else if (!this.config.mockServerEnabled && this.isListening) {
164-
this.stopServer();
165-
}
166-
});
160+
// The config "changes" from the default at startup, so we need to call onConfigChange() to ensure the server is
161+
// started if required.
162+
this.onConfigChange();
163+
this.config.onDidChangeConfiguration(() => this.onConfigChange());
164+
}
165+
166+
private onConfigChange(): void {
167+
if (this.config.mockServerEnabled && !this.isListening) {
168+
this.startServer();
169+
} else if (!this.config.mockServerEnabled && this.isListening) {
170+
this.stopServer();
171+
}
167172
}
168173
}

0 commit comments

Comments
 (0)