Skip to content

Commit fa56ea8

Browse files
committed
Extract status file path helper
1 parent 657f337 commit fa56ea8

File tree

3 files changed

+27
-21
lines changed

3 files changed

+27
-21
lines changed

lib/init-action-post.js

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init-action.js

Lines changed: 9 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/overlay/status.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ const MAX_CACHE_OPERATION_MS = 30_000;
2828
/** File name for the serialized overlay status. */
2929
const STATUS_FILE_NAME = "overlay-status.json";
3030

31+
/** Path to the local overlay status file. */
32+
function getStatusFilePath(languages: string[]): string {
33+
return path.join(
34+
getTemporaryDirectory(),
35+
"overlay-status",
36+
[...languages].sort().join("+"),
37+
STATUS_FILE_NAME,
38+
);
39+
}
40+
3141
/** Status of an overlay analysis for a set of languages. */
3242
export interface OverlayStatus {
3343
/** Whether the job attempted to build an overlay base database. */
@@ -78,12 +88,7 @@ export async function getOverlayStatus(
7888
logger: Logger,
7989
): Promise<OverlayStatus | undefined> {
8090
const cacheKey = await getCacheKey(codeql, languages, diskUsage);
81-
const statusFile = path.join(
82-
getTemporaryDirectory(),
83-
"overlay-status",
84-
[...languages].sort().join("+"),
85-
STATUS_FILE_NAME,
86-
);
91+
const statusFile = getStatusFilePath(languages);
8792
await fs.promises.mkdir(path.dirname(statusFile), { recursive: true });
8893

8994
try {
@@ -129,12 +134,7 @@ export async function saveOverlayStatus(
129134
logger: Logger,
130135
): Promise<boolean> {
131136
const cacheKey = await getCacheKey(codeql, languages, diskUsage);
132-
const statusFile = path.join(
133-
getTemporaryDirectory(),
134-
"overlay-status",
135-
[...languages].sort().join("+"),
136-
STATUS_FILE_NAME,
137-
);
137+
const statusFile = getStatusFilePath(languages);
138138
await fs.promises.mkdir(path.dirname(statusFile), { recursive: true });
139139
await fs.promises.writeFile(statusFile, JSON.stringify(status));
140140

0 commit comments

Comments
 (0)