Start mock server on startup

The mock server wasn't being started when the extension was activated
when the config setting was already set.
This commit is contained in:
Koen Vlaswinkel
2022-10-21 11:39:29 +02:00
parent 302722b982
commit 74ae5a7fdc

View File

@@ -157,12 +157,17 @@ export class MockGitHubApiServer extends DisposableObject {
}
private setupConfigListener(): void {
this.config.onDidChangeConfiguration(() => {
if (this.config.mockServerEnabled && !this.isListening) {
this.startServer();
} else if (!this.config.mockServerEnabled && this.isListening) {
this.stopServer();
}
});
// The config "changes" from the default at startup, so we need to call onConfigChange() to ensure the server is
// started if required.
this.onConfigChange();
this.config.onDidChangeConfiguration(() => this.onConfigChange());
}
private onConfigChange(): void {
if (this.config.mockServerEnabled && !this.isListening) {
this.startServer();
} else if (!this.config.mockServerEnabled && this.isListening) {
this.stopServer();
}
}
}