mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-23 12:54:42 +00:00
convert wrappers to use sync runtime
This commit is contained in:
parent
e74c99320f
commit
ef2faaac4c
1 changed files with 5 additions and 15 deletions
20
packages/opencode/src/env/index.ts
vendored
20
packages/opencode/src/env/index.ts
vendored
|
|
@ -1,4 +1,5 @@
|
|||
import { InstanceState } from "@/effect/instance-state"
|
||||
import { makeRuntime } from "@/effect/run-service"
|
||||
import { Context, Effect, Layer } from "effect"
|
||||
|
||||
export namespace Env {
|
||||
|
|
@ -45,20 +46,9 @@ export namespace Env {
|
|||
)
|
||||
|
||||
export const defaultLayer = layer
|
||||
const rt = makeRuntime(Service, layer)
|
||||
|
||||
export const get = Effect.fn("Env.get")(function* (key: string) {
|
||||
return yield* (yield* Service).get(key)
|
||||
})
|
||||
|
||||
export const all = Effect.fn("Env.all")(function* () {
|
||||
return yield* (yield* Service).all()
|
||||
})
|
||||
|
||||
export const set = Effect.fn("Env.set")(function* (key: string, value: string) {
|
||||
yield* (yield* Service).set(key, value)
|
||||
})
|
||||
|
||||
export const remove = Effect.fn("Env.remove")(function* (key: string) {
|
||||
yield* (yield* Service).remove(key)
|
||||
})
|
||||
export function set(key: string, value: string) {
|
||||
return rt.runSync((svc) => svc.set(key, value))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue