| 80 | const env = process.env |
| 81 | |
| 82 | function createImportMetaEnvProxy(): WorkerGlobalState['metaEnv'] { |
| 83 | // packages/vitest/src/node/plugins/index.ts:146 |
| 84 | const booleanKeys = ['DEV', 'PROD', 'SSR'] |
| 85 | return new Proxy(env, { |
| 86 | get(_, key) { |
| 87 | if (typeof key !== 'string') { |
| 88 | return undefined |
| 89 | } |
| 90 | if (booleanKeys.includes(key)) { |
| 91 | return !!process.env[key] |
| 92 | } |
| 93 | return process.env[key] |
| 94 | }, |
| 95 | set(_, key, value) { |
| 96 | if (typeof key !== 'string') { |
| 97 | return true |
| 98 | } |
| 99 | |
| 100 | if (booleanKeys.includes(key)) { |
| 101 | process.env[key] = value ? '1' : '' |
| 102 | } |
| 103 | else { |
| 104 | process.env[key] = value |
| 105 | } |
| 106 | |
| 107 | return true |
| 108 | }, |
| 109 | }) as WorkerGlobalState['metaEnv'] |
| 110 | } |