-
Notifications
You must be signed in to change notification settings - Fork 226
Restart query server when external config changes #2289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -19,6 +19,7 @@ import { join } from "path"; | |||||
| import { dirSync } from "tmp-promise"; | ||||||
| import { testExplorerExtensionId, TestHub } from "vscode-test-adapter-api"; | ||||||
| import { lt, parse } from "semver"; | ||||||
| import { watch } from "chokidar"; | ||||||
|
|
||||||
| import { AstViewer } from "./astViewer"; | ||||||
| import { | ||||||
|
|
@@ -194,6 +195,7 @@ function getCommands( | |||||
| "codeQL.restartQueryServer": restartQueryServer, | ||||||
| "codeQL.restartQueryServerOnConfigChange": restartQueryServer, | ||||||
| "codeQL.restartLegacyQueryServerOnConfigChange": restartQueryServer, | ||||||
| "codeQL.restartQueryServerOnExternalConfigChange": restartQueryServer, | ||||||
| "codeQL.copyVersion": async () => { | ||||||
| const text = `CodeQL extension version: ${ | ||||||
| extension?.packageJSON.version | ||||||
|
|
@@ -672,6 +674,7 @@ async function activateWithInstalledDistribution( | |||||
| extLogger, | ||||||
| ); | ||||||
| ctx.subscriptions.push(cliServer); | ||||||
| watchExternalConfigFile(app, ctx); | ||||||
|
|
||||||
| const statusBar = new CodeQlStatusBarHandler( | ||||||
| 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) { | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we not want to have this work on Windows? It seems like we can call
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah...right. I forgot about that. I will fix. |
||||||
| const configPath = join(process.env.HOME, ".config/codeql", "config"); | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be better to be consistent in how we join here:
Suggested change
|
||||||
| 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( | ||||||
| compareView: CompareView, | ||||||
| from: CompletedLocalQueryInfo, | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.