MCPcopy
hub / github.com/anomalyco/opencode / withTmp

Function withTmp

packages/opencode/test/plugin/loader-shared.test.ts:28–37  ·  view source on GitHub ↗
(
  init: (dir: string) => Promise<T>,
  body: (tmp: { path: string; extra: T }) => Effect.Effect<A, E, R>,
)

Source from the content-addressed store, hash-verified

26)
27
28function withTmp<T, A, E, R>(
29 init: (dir: string) => Promise<T>,
30 body: (tmp: { path: string; extra: T }) => Effect.Effect<A, E, R>,
31) {
32 return Effect.gen(function* () {
33 const dir = yield* tmpdirScoped()
34 const extra = yield* Effect.promise(() => init(dir))
35 return yield* body({ path: dir, extra })
36 })
37}
38
39function load(dir: string, flags?: Parameters<typeof RuntimeFlags.layer>[0]) {
40 const source = path.join(dir, "opencode.json")

Callers 1

Calls 3

tmpdirScopedFunction · 0.90
initFunction · 0.50
bodyFunction · 0.50

Tested by

no test coverage detected