(patch: Record<string, string | undefined>, fn: () => void)
| 18 | } from '../src/ui/glyphs'; |
| 19 | |
| 20 | function 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 | |
| 41 | function setPlatform(value: NodeJS.Platform): void { |
| 42 | Object.defineProperty(process, 'platform', { value }); |
no test coverage detected