Refactor output-caching functions to accept file path dependency

This makes it easier to test. Credit to @mbg.
This commit is contained in:
Mario Campos
2026-08-14 14:41:04 -05:00
parent b5d34388b7
commit fcd8d74cda
5 changed files with 70 additions and 57 deletions

View File

@@ -491,7 +491,12 @@ async function getCodeQLForCmd(
return cmd;
},
async getVersion() {
let result = outputCache.getCachedCodeQlVersion(logger, getEnv(), cmd);
const cacheFilePath = outputCache.getCommandCacheFilePath(getEnv());
let result = outputCache.getCachedCodeQlVersion(
logger,
cacheFilePath,
cmd,
);
if (result === undefined) {
result = await runCliJson<VersionInfo>(
cmd,
@@ -500,7 +505,7 @@ async function getCodeQLForCmd(
noStreamStdout: true,
},
);
outputCache.cacheCodeQlVersion(getEnv(), cmd, result);
outputCache.cacheCodeQlVersion(cacheFilePath, cmd, result);
}
return result;
},