mirror of
https://github.com/github/codeql-action.git
synced 2026-08-05 04:57:19 -05:00
Refactor CLI executions into helper functions
This provides a separation of concerns between the memoization and the execution.
This commit is contained in:
+6
-3
@@ -731,8 +731,7 @@ async function getCodeQLForCmd(
|
||||
filterToLanguagesWithQueries: boolean;
|
||||
} = { filterToLanguagesWithQueries: false },
|
||||
) {
|
||||
let result = util.getCachedCodeQlResolveLanguages(cmd);
|
||||
if (result === undefined) {
|
||||
async function runCliResolveLanguages() {
|
||||
const codeqlArgs = [
|
||||
"resolve",
|
||||
"languages",
|
||||
@@ -747,12 +746,16 @@ async function getCodeQLForCmd(
|
||||
const output = await runCli(cmd, codeqlArgs);
|
||||
|
||||
try {
|
||||
result = JSON.parse(output) as ResolveLanguagesOutput;
|
||||
return JSON.parse(output) as ResolveLanguagesOutput;
|
||||
} catch (e) {
|
||||
throw new Error(
|
||||
`Unexpected output from codeql resolve languages with --format=betterjson: ${e}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
let result = util.getCachedCodeQlResolveLanguages(cmd);
|
||||
if (result === undefined) {
|
||||
result = await runCliResolveLanguages();
|
||||
util.cacheCodeQlResolveLanguages(cmd, result);
|
||||
}
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user