Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

compileCache.ts

19 lines880 Bytes

1// @effect-diagnostics nodeBuiltinImport:off
2import * as NodeModule from "node:module";
3import * as NodeOS from "node:os";
4import * as NodePath from "node:path";
5​
6// Linux uses the user's cache dir because /tmp is shared between users; the macOS and Windows
7// temp dirs are already per user. Skipped under AppImage: it mounts the app at a new
8// /tmp/.mount_* path each launch, and Node keys entries by path, so every launch would miss
9// and leave another copy behind.
10try {
11 if (!process.env.APPIMAGE) {
12 const cacheRoot =
13 // oxlint-disable-next-line t3code/no-global-process-runtime -- Loads before any Effect runtime.
14 process.platform === "linux"
15 ? process.env.XDG_CACHE_HOME || NodePath.join(NodeOS.homedir(), ".cache")
16 : NodeOS.tmpdir();
17 NodeModule.enableCompileCache(NodePath.join(cacheRoot, "t3code", "compile-cache"));
18 }
19} catch {}