MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / withEnv

Function withEnv

__tests__/glyphs.test.ts:20–39  ·  view source on GitHub ↗
(patch: Record<string, string | undefined>, fn: () => void)

Source from the content-addressed store, hash-verified

18} from '../src/ui/glyphs';
19
20function withEnv(patch: Record<string, string | undefined>, fn: () => void): void {
21 const saved: Record<string, string | undefined> = {};
22 const savedPlatform = process.platform;
23 for (const key of Object.keys(patch)) {
24 saved[key] = process.env[key];
25 if (patch[key] === undefined) delete process.env[key];
26 else process.env[key] = patch[key];
27 }
28 _resetGlyphsCache();
29 try {
30 fn();
31 } finally {
32 for (const key of Object.keys(saved)) {
33 if (saved[key] === undefined) delete process.env[key];
34 else process.env[key] = saved[key];
35 }
36 Object.defineProperty(process, 'platform', { value: savedPlatform });
37 _resetGlyphsCache();
38 }
39}
40
41function setPlatform(value: NodeJS.Platform): void {
42 Object.defineProperty(process, 'platform', { value });

Callers 1

glyphs.test.tsFile · 0.85

Calls 2

_resetGlyphsCacheFunction · 0.90
fnFunction · 0.70

Tested by

no test coverage detected