From 65c15afe9f78f2b0d2f400e94fab3194e81c77cc Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Thu, 30 Apr 2026 11:48:13 -0400 Subject: test: use testEffect for instruction tests (#25046) --- packages/core/src/global.ts | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'packages/core/src') 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 { + 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) => + Layer.effect( + Service, + Effect.sync(() => Service.of(make(input))), + ) + export * as Global from "./global" -- cgit v1.2.3