diff options
| author | Kit Langton <[email protected]> | 2026-04-30 11:48:13 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-04-30 11:48:13 -0400 |
| commit | 65c15afe9f78f2b0d2f400e94fab3194e81c77cc (patch) | |
| tree | dcbd0be583beeecf19d72231f7aef2991b2c78a5 /packages/core/src | |
| parent | 8f57a2a46225109fbd1f74e545e22a9378f777b4 (diff) | |
| download | opencode-65c15afe9f78f2b0d2f400e94fab3194e81c77cc.tar.gz opencode-65c15afe9f78f2b0d2f400e94fab3194e81c77cc.zip | |
test: use testEffect for instruction tests (#25046)
Diffstat (limited to 'packages/core/src')
| -rw-r--r-- | packages/core/src/global.ts | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/packages/core/src/global.ts b/packages/core/src/global.ts index 0c83e3a1f..42e0f1030 100644 --- a/packages/core/src/global.ts +++ b/packages/core/src/global.ts @@ -4,6 +4,7 @@ import { xdgData, xdgCache, xdgConfig, xdgState } from "xdg-basedir" import os from "os" import { Context, Effect, Layer } from "effect" import { Flock } from "./util/flock" +import { Flag } from "./flag/flag" const app = "opencode" const data = path.join(xdgData!, app) @@ -47,19 +48,28 @@ export interface Interface { readonly log: string } +export function make(input: Partial<Interface> = {}): Interface { + return { + home: Path.home, + data: Path.data, + cache: Path.cache, + config: Flag.OPENCODE_CONFIG_DIR ?? Path.config, + state: Path.state, + bin: Path.bin, + log: Path.log, + ...input, + } +} + export const layer = Layer.effect( Service, - Effect.gen(function* () { - return Service.of({ - home: Path.home, - data: Path.data, - cache: Path.cache, - config: Path.config, - state: Path.state, - bin: Path.bin, - log: Path.log, - }) - }), + Effect.sync(() => Service.of(make())), ) +export const layerWith = (input: Partial<Interface>) => + Layer.effect( + Service, + Effect.sync(() => Service.of(make(input))), + ) + export * as Global from "./global" |
