Skip to content

Commit 6c0d901

Browse files
committed
Change OutputCache to use object for entries
This will ensure it works nicely with `JSON.stringify`. And, then we can validate the type before marshaling.
1 parent bf96b0d commit 6c0d901

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

‎lib/entry-points.js‎

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/cli/output-cache.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ export type CommandCacheKeyOutputMap = {
2525
*/
2626
export interface OutputCache<K extends CommandCacheKey> {
2727
cmd: string;
28-
entries: Map<K, CommandCacheKeyOutputMap[K]>;
28+
entries: {
29+
[P in K]: CommandCacheKeyOutputMap[K];
30+
};
2931
}
3032

3133
/**
@@ -70,13 +72,17 @@ export function cacheCodeQlVersion(
7072
throw new Error("cacheCodeQlVersion() should be called only once");
7173
}
7274
cachedCodeQlVersion = version;
75+
const outputCache = {
76+
cmd,
77+
entries: { [CommandCacheKey.Version]: version },
78+
} satisfies OutputCache<CommandCacheKey.Version>;
7379
// Persist the version so that subsequent Actions steps, which run in separate
7480
// processes, can reuse it rather than invoking `codeql version` again. We
7581
// record the CLI path so that a different step using a different CodeQL bundle
7682
// doesn't pick up a stale version.
7783
fs.writeFileSync(
7884
getCommandCacheFilePath(env),
79-
JSON.stringify({ cmd, entries: { [CommandCacheKey.Version]: version } }),
85+
JSON.stringify(outputCache),
8086
"utf8",
8187
);
8288
}

0 commit comments

Comments
 (0)