MCPcopy Index your code
hub / github.com/anomalyco/opencode / withProcessEnvs

Function withProcessEnvs

packages/opencode/test/config/config.test.ts:240–260  ·  view source on GitHub ↗
(entries: Record<string, string | undefined>, effect: Effect.Effect<A, E, R>)

Source from the content-addressed store, hash-verified

238}
239
240function withProcessEnvs<A, E, R>(entries: Record<string, string | undefined>, effect: Effect.Effect<A, E, R>) {
241 return Effect.acquireUseRelease(
242 Effect.sync(() => {
243 const originals: Record<string, string | undefined> = {}
244 for (const [key, value] of Object.entries(entries)) {
245 originals[key] = process.env[key]
246 if (value === undefined) delete process.env[key]
247 else process.env[key] = value
248 }
249 return originals
250 }),
251 () => effect,
252 (originals) =>
253 Effect.sync(() => {
254 for (const [key, original] of Object.entries(originals)) {
255 if (original !== undefined) process.env[key] = original
256 else delete process.env[key]
257 }
258 }),
259 )
260}
261
262async function check(map: (dir: string) => string) {
263 if (process.platform !== "win32") return

Callers 2

withProcessEnvFunction · 0.85
config.test.tsFile · 0.85

Calls 1

syncMethod · 0.80

Tested by

no test coverage detected