mirror of
https://github.com/anomalyco/opencode.git
synced 2026-10-25 07:30:31 +00:00
26 lines
1 KiB
TypeScript
26 lines
1 KiB
TypeScript
import os from "node:os"
|
|
import path from "node:path"
|
|
|
|
// Each isolated home gets its own XDG_CACHE_HOME, where Bun would otherwise keep its transpiler cache,
|
|
// so every spawned CLI process would transpile the source from scratch. Share one cache instead.
|
|
export const transpilerCache = path.join(os.tmpdir(), "opencode-test-transpiler-cache")
|
|
|
|
export function isolatedEnv(root: string, overrides: Record<string, string | undefined> = {}) {
|
|
return {
|
|
...process.env,
|
|
BUN_RUNTIME_TRANSPILER_CACHE_PATH: transpilerCache,
|
|
HOME: root,
|
|
OPENCODE_CLI_CONFIG_CONTENT: undefined,
|
|
OPENCODE_CONFIG_CONTENT: "{}",
|
|
OPENCODE_CONFIG_DIR: path.join(root, "config"),
|
|
OPENCODE_DB: path.join(root, "opencode.db"),
|
|
OPENCODE_DISABLE_FILEWATCHER: "true",
|
|
OPENCODE_DISABLE_MODELS_FETCH: "true",
|
|
OPENCODE_TEST_HOME: root,
|
|
XDG_CACHE_HOME: path.join(root, "cache"),
|
|
XDG_CONFIG_HOME: path.join(root, "xdg-config"),
|
|
XDG_DATA_HOME: path.join(root, "data"),
|
|
XDG_STATE_HOME: path.join(root, "state"),
|
|
...overrides,
|
|
}
|
|
}
|