Files
scriptc/packages/compiler/src/backend/cache-root.ts
T
Chris Tate ee9f0d64eb feat: ship the self-hosted native scriptc CLI (#585)
* feat: ship the self-hosted native scriptc CLI

- Run the shared compiler and CLI natively, including library builds and compile-time evaluation.
- Install native platform packages and ship relocatable standalone distributions.
- Preserve program semantics and reuse validated build artifacts for fast rebuilds.

* fix: complete native CLI integration and validation

- Preserve library diagnostics and run recursive compiler work on the main stack.
- Restore packaged helper permissions and exercise native npm and Wasm library builds.
- Recover interrupted Sandbox status probes within the original command deadline.
2026-09-30 02:17:56 -05:00

25 lines
1.0 KiB
TypeScript

import { homedir } from "node:os";
import { resolve } from "node:path";
/** Resolve the build cache without touching the filesystem. Exported from this
* internal module so its platform and override behavior can be pinned directly. */
export function resolveBuildCacheRoot(
env: NodeJS.ProcessEnv = process.env,
platform: NodeJS.Platform = process.platform,
userHome: string = homedir(),
): string | null {
if (env["SCRIPTC_NO_CACHE"] === "1") return null;
const configured = env["SCRIPTC_CACHE_DIR"];
if (configured !== undefined) return configured === "" ? null : resolve(configured);
const xdg = env["XDG_CACHE_HOME"];
if (xdg !== undefined && xdg !== "") return resolve(xdg, "scriptc", "build");
if (platform === "win32") {
const local = env["LOCALAPPDATA"];
if (local !== undefined && local !== "") return resolve(local, "scriptc", "cache", "build");
}
return platform === "darwin"
? resolve(userHome, "Library", "Caches", "scriptc", "build")
: resolve(userHome, ".cache", "scriptc", "build");
}