feat: centralize runtime directories behind GHBOT_RUNTIME_DIR (D-13)

This commit is contained in:
wdawdwa committed 2026-08-23 11:26:48 +08:00
1 parent 941e1d2681
commit d9666c94a7
7 files changed
+64 -6

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
import path from "node:path";
import process from "node:process";
/**
* Runtime scratch/cache directories live under one configurable root so
* deployments with read-only or restricted working directories (D-13) can move
* them without code changes. Defaults to the process working directory.
*/
export function runtimeDirectory(): string {
const configured = process.env.GHBOT_RUNTIME_DIR?.trim();
return configured ? configured : process.cwd();
}
export function tempRootDirectory(): string {
return path.join(runtimeDirectory(), ".ghbot-tmp");
}
export function cacheRootDirectory(): string {
return path.join(runtimeDirectory(), ".ghbot-cache");
}