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

Function run

packages/core/test/lib/effect.ts:11–20  ·  view source on GitHub ↗
(value: Body<A, E, R | Scope.Scope>, layer: Layer.Layer<R, E2>)

Source from the content-addressed store, hash-verified

9const body = <A, E, R>(value: Body<A, E, R>) => Effect.suspend(() => (typeof value === "function" ? value() : value))
10
11const run = <A, E, R, E2>(value: Body<A, E, R | Scope.Scope>, layer: Layer.Layer<R, E2>) =>
12 Effect.gen(function* () {
13 const exit = yield* body(value).pipe(Effect.scoped, Effect.provide(layer), Effect.exit)
14 if (Exit.isFailure(exit)) {
15 for (const err of Cause.prettyErrors(exit.cause)) {
16 yield* Effect.logError(err)
17 }
18 }
19 return yield* exit
20 }).pipe(Effect.runPromise)
21
22const make = <R, E>(testLayer: Layer.Layer<R, E>, liveLayer: Layer.Layer<R, E>) => {
23 const effect = <A, E2>(name: string, value: Body<A, E2, R | Scope.Scope>, opts?: number | TestOptions) =>

Callers 4

effectFunction · 0.70
makeFunction · 0.70
liveFunction · 0.70
instrumentWritesFunction · 0.50

Calls 1

bodyFunction · 0.70

Tested by 1

instrumentWritesFunction · 0.40