mirror of
https://github.com/Heretek-AI/opencode.git
synced 2026-11-22 23:47:02 -10:00
40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
import fs from "node:fs/promises"
|
|
import { Effect } from "effect"
|
|
import { ChildProcessSpawner } from "effect/unstable/process"
|
|
import { CrossSpawnSpawner } from "@opencode-ai/util/cross-spawn-spawner"
|
|
import { LayerNode } from "@opencode-ai/util/effect/layer-node"
|
|
import { execDefaults, Failed, makeFiles, makeMemoryDriver } from "../src/environment/index"
|
|
import { tmpdir } from "./fixture/tmpdir"
|
|
import { environmentConformance } from "./lib/environment-conformance"
|
|
|
|
environmentConformance("memory environment", () =>
|
|
Effect.sync(() => {
|
|
const driver = makeMemoryDriver()
|
|
return {
|
|
files: makeFiles(driver),
|
|
root: `/workspace-${crypto.randomUUID()}`,
|
|
symlink: driver.symlink,
|
|
}
|
|
}),
|
|
)
|
|
|
|
environmentConformance(
|
|
"GNU exec environment",
|
|
() =>
|
|
Effect.gen(function* () {
|
|
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner
|
|
const tmp = yield* Effect.promise(() => tmpdir("opencode-environment-"))
|
|
return {
|
|
files: execDefaults(spawner),
|
|
root: tmp.path,
|
|
symlink: (target: string, link: string) =>
|
|
Effect.tryPromise({
|
|
try: () => fs.symlink(target, link),
|
|
catch: (cause) => new Failed({ path: link, cause }),
|
|
}),
|
|
dispose: Effect.promise(() => tmp[Symbol.asyncDispose]()),
|
|
}
|
|
}).pipe(Effect.provide(LayerNode.compile(CrossSpawnSpawner.node))),
|
|
process.platform !== "linux",
|
|
)
|