Restart query server when external config changes
This avoids manually restarting the query server when this file changes.
This commit is contained in:
@@ -71,6 +71,7 @@ export type BaseCommands = {
|
|||||||
"codeQL.restartQueryServer": () => Promise<void>;
|
"codeQL.restartQueryServer": () => Promise<void>;
|
||||||
"codeQL.restartQueryServerOnConfigChange": () => Promise<void>;
|
"codeQL.restartQueryServerOnConfigChange": () => Promise<void>;
|
||||||
"codeQL.restartLegacyQueryServerOnConfigChange": () => Promise<void>;
|
"codeQL.restartLegacyQueryServerOnConfigChange": () => Promise<void>;
|
||||||
|
"codeQL.restartQueryServerOnExternalConfigChange": () => Promise<void>;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Commands used when working with queries in the editor
|
// Commands used when working with queries in the editor
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import { join } from "path";
|
|||||||
import { dirSync } from "tmp-promise";
|
import { dirSync } from "tmp-promise";
|
||||||
import { testExplorerExtensionId, TestHub } from "vscode-test-adapter-api";
|
import { testExplorerExtensionId, TestHub } from "vscode-test-adapter-api";
|
||||||
import { lt, parse } from "semver";
|
import { lt, parse } from "semver";
|
||||||
|
import { watch } from "chokidar";
|
||||||
|
|
||||||
import { AstViewer } from "./astViewer";
|
import { AstViewer } from "./astViewer";
|
||||||
import {
|
import {
|
||||||
@@ -194,6 +195,7 @@ function getCommands(
|
|||||||
"codeQL.restartQueryServer": restartQueryServer,
|
"codeQL.restartQueryServer": restartQueryServer,
|
||||||
"codeQL.restartQueryServerOnConfigChange": restartQueryServer,
|
"codeQL.restartQueryServerOnConfigChange": restartQueryServer,
|
||||||
"codeQL.restartLegacyQueryServerOnConfigChange": restartQueryServer,
|
"codeQL.restartLegacyQueryServerOnConfigChange": restartQueryServer,
|
||||||
|
"codeQL.restartQueryServerOnExternalConfigChange": restartQueryServer,
|
||||||
"codeQL.copyVersion": async () => {
|
"codeQL.copyVersion": async () => {
|
||||||
const text = `CodeQL extension version: ${
|
const text = `CodeQL extension version: ${
|
||||||
extension?.packageJSON.version
|
extension?.packageJSON.version
|
||||||
@@ -672,6 +674,7 @@ async function activateWithInstalledDistribution(
|
|||||||
extLogger,
|
extLogger,
|
||||||
);
|
);
|
||||||
ctx.subscriptions.push(cliServer);
|
ctx.subscriptions.push(cliServer);
|
||||||
|
watchExternalConfigFile(app, ctx);
|
||||||
|
|
||||||
const statusBar = new CodeQlStatusBarHandler(
|
const statusBar = new CodeQlStatusBarHandler(
|
||||||
cliServer,
|
cliServer,
|
||||||
@@ -1010,6 +1013,33 @@ async function activateWithInstalledDistribution(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle changes to the external config file. This is used to restart the query server
|
||||||
|
* when the user changes options.
|
||||||
|
* See https://docs.github.com/en/code-security/codeql-cli/using-the-codeql-cli/specifying-command-options-in-a-codeql-configuration-file#using-a-codeql-configuration-file
|
||||||
|
*/
|
||||||
|
function watchExternalConfigFile(app: ExtensionApp, ctx: ExtensionContext) {
|
||||||
|
if (process.env.HOME) {
|
||||||
|
const configPath = join(process.env.HOME, ".config/codeql", "config");
|
||||||
|
const configWatcher = watch(configPath, {
|
||||||
|
// These options avoid firing the event twice.
|
||||||
|
persistent: true,
|
||||||
|
ignoreInitial: true,
|
||||||
|
awaitWriteFinish: true,
|
||||||
|
});
|
||||||
|
configWatcher.on("all", async () => {
|
||||||
|
await app.commands.execute(
|
||||||
|
"codeQL.restartQueryServerOnExternalConfigChange",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
ctx.subscriptions.push({
|
||||||
|
dispose: () => {
|
||||||
|
void configWatcher.close();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function showResultsForComparison(
|
async function showResultsForComparison(
|
||||||
compareView: CompareView,
|
compareView: CompareView,
|
||||||
from: CompletedLocalQueryInfo,
|
from: CompletedLocalQueryInfo,
|
||||||
|
|||||||
Reference in New Issue
Block a user