| 123456789101112131415161718192021222324252627 |
- import path from "path"
- import { Global } from "@opencode-ai/util/global"
- import { Effect, Layer } from "effect"
- import { tmpdir } from "./tmpdir"
- export const tempGlobalLayer = Layer.unwrap(
- Effect.acquireRelease(
- Effect.promise(() => tmpdir()),
- (tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()),
- ).pipe(
- Effect.map((tmp) => {
- const data = path.join(tmp.path, "data")
- const cache = path.join(tmp.path, "cache")
- return Global.layerWith({
- home: path.join(tmp.path, "home"),
- data,
- cache,
- config: path.join(tmp.path, "config"),
- state: path.join(tmp.path, "state"),
- tmp: path.join(tmp.path, "tmp"),
- bin: path.join(cache, "bin"),
- log: path.join(data, "log"),
- repos: path.join(data, "repos"),
- })
- }),
- ),
- )
|