From 889ae42672fcfc9f2570842bca674d6989c02f69 Mon Sep 17 00:00:00 2001 From: Mario Campos Date: Wed, 17 Jun 2026 16:11:40 -0500 Subject: [PATCH] Refactor CLI executions into helper functions This provides a separation of concerns between the memoization and the execution. --- src/codeql.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/codeql.ts b/src/codeql.ts index 626d1021a..23de25a7a 100644 --- a/src/codeql.ts +++ b/src/codeql.ts @@ -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;