Skip to content
Source
Sign inSign up

cliCompileCache.ts

17 lines815 Bytes

1// @effect-diagnostics nodeBuiltinImport:off -- Runs before the CLI's Effect runtime loads.
2import * as NodeModule from "node:module";
3import * as NodeOS from "node:os";
4import * as NodePath from "node:path";
5import * as NodeSea from "node:sea";
6​
7export function enableCliCompileCache(): void {
8 try {
9 // AppImage paths change each launch; SEA has no separate modules to cache.
10 if (process.env.APPIMAGE || NodeSea.isSea()) return;
11 const cacheRoot =
12 process.env.XDG_CACHE_HOME ||
13 // oxlint-disable-next-line t3code/no-global-process-runtime -- Runs before the CLI's Effect runtime loads.
14 (process.platform === "linux" ? NodePath.join(NodeOS.homedir(), ".cache") : NodeOS.tmpdir());
15 NodeModule.enableCompileCache(NodePath.join(cacheRoot, "t3code", "compile-cache"));
16 } catch {}