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

Function withEnv

packages/core/test/plugin/provider-gitlab.test.ts:23–42  ·  view source on GitHub ↗
(vars: Record<string, string | undefined>, effect: () => Effect.Effect<A, E, R>)

Source from the content-addressed store, hash-verified

21})
22
23function withEnv<A, E, R>(vars: Record<string, string | undefined>, effect: () => Effect.Effect<A, E, R>) {
24 return Effect.acquireUseRelease(
25 Effect.sync(() => {
26 const previous = Object.fromEntries(Object.keys(vars).map((key) => [key, process.env[key]]))
27 Object.entries(vars).forEach(([key, value]) => {
28 if (value === undefined) delete process.env[key]
29 else process.env[key] = value
30 })
31 return previous
32 }),
33 effect,
34 (previous) =>
35 Effect.sync(() =>
36 Object.entries(previous).forEach(([key, value]) => {
37 if (value === undefined) delete process.env[key]
38 else process.env[key] = value
39 }),
40 ),
41 )
42}
43
44void mock.module("gitlab-ai-provider", () => ({
45 VERSION: "test-version",

Callers 1

Calls 1

syncMethod · 0.80

Tested by

no test coverage detected