mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-03 07:54:40 +08:00
* 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.
25 lines
1.0 KiB
TypeScript
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");
|
|
}
|