(
overrides: Record<string, string | undefined> = {},
options: { clear?: boolean } = {},
)
| 93 | } |
| 94 | |
| 95 | export function mockProcessEnv( |
| 96 | overrides: Record<string, string | undefined> = {}, |
| 97 | options: { clear?: boolean } = {}, |
| 98 | ): () => void { |
| 99 | const originalEnv = { ...process.env }; |
| 100 | |
| 101 | if (options.clear) { |
| 102 | replaceProcessEnv({}); |
| 103 | } |
| 104 | |
| 105 | for (const [key, value] of Object.entries(overrides)) { |
| 106 | if (value === undefined) { |
| 107 | Reflect.deleteProperty(process.env, key); |
| 108 | } else { |
| 109 | Object.assign(process.env, { [key]: value }); |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | return () => { |
| 114 | replaceProcessEnv(originalEnv); |
| 115 | }; |
| 116 | } |
| 117 | |
| 118 | export const PROXY_ENV_KEYS = [ |
| 119 | 'HTTP_PROXY', |
searching dependent graphs…