Cache result of codeql version

This commit is contained in:
Edoardo Pirovano 2021-08-18 09:25:16 +01:00
parent f0a2954c12
commit 4ba53e33d7
No known key found for this signature in database
GPG key ID: 047556B5D93FFE28
3 changed files with 9 additions and 3 deletions

5
lib/codeql.js generated
View file

@ -321,12 +321,15 @@ function getCachedCodeQL() {
}
exports.getCachedCodeQL = getCachedCodeQL;
function getCodeQLForCmd(cmd) {
let cachedVersion = undefined;
return {
getPath() {
return cmd;
},
async getVersion() {
return await runTool(cmd, ["version", "--format=terse"]);
if (cachedVersion === undefined)
cachedVersion = runTool(cmd, ["version", "--format=terse"]);
return await cachedVersion;
},
async printVersion() {
await runTool(cmd, ["version", "--format=json"]);

File diff suppressed because one or more lines are too long

View file

@ -543,12 +543,15 @@ export function getCachedCodeQL(): CodeQL {
}
function getCodeQLForCmd(cmd: string): CodeQL {
let cachedVersion: undefined | Promise<string> = undefined;
return {
getPath() {
return cmd;
},
async getVersion() {
return await runTool(cmd, ["version", "--format=terse"]);
if (cachedVersion === undefined)
cachedVersion = runTool(cmd, ["version", "--format=terse"]);
return await cachedVersion;
},
async printVersion() {
await runTool(cmd, ["version", "--format=json"]);