Introduce forceUpdateConfiguration method

This commit is contained in:
Koen Vlaswinkel
2023-11-24 15:36:27 +01:00
parent 54be065f3e
commit cab510f2dd
2 changed files with 14 additions and 6 deletions

View File

@@ -119,6 +119,14 @@ export interface DistributionConfig {
ownerName?: string;
repositoryName?: string;
onDidChangeConfiguration?: Event<void>;
/**
* This forces an update of the distribution, even if the settings haven't changed.
*
* This should only be used when the distribution has been updated outside of the extension
* and only in tests. It should not be called in production code.
*/
forceUpdateConfiguration(): void;
}
// Query server configuration
@@ -275,6 +283,10 @@ export class DistributionConfigListener
);
}
public forceUpdateConfiguration() {
this._onDidChangeConfiguration.fire(undefined);
}
protected handleDidChangeConfiguration(e: ConfigurationChangeEvent): void {
this.handleDidChangeConfigurationForRelevantSettings(
DISTRIBUTION_CHANGE_SETTINGS,

View File

@@ -39,15 +39,11 @@ beforeAll(async () => {
const cliVersion = await extension.cliServer.getVersion();
if (cliVersion.compare(process.env.CLI_VERSION) !== 0) {
// This calls the private `updateConfiguration` method in the `ConfigListener`
// It seems like the CUSTOM_CODEQL_PATH_SETTING.updateValue() call in
// `beforeAllAction` doesn't fire the event that the config has changed.
// `forceUpdateConfiguration` will fire the event manually.
// This is a hacky workaround.
(
extension.distributionManager.config as unknown as {
updateConfiguration: () => void;
}
).updateConfiguration();
extension.distributionManager.config.forceUpdateConfiguration();
}
}
});