(value, fn)
| 45 | |
| 46 | // Helper: temporarily override process.platform without leaking state. |
| 47 | function withPlatform(value, fn) { |
| 48 | const desc = Object.getOwnPropertyDescriptor(process, 'platform'); |
| 49 | Object.defineProperty(process, 'platform', { value, configurable: true }); |
| 50 | try { |
| 51 | return fn(); |
| 52 | } finally { |
| 53 | Object.defineProperty(process, 'platform', desc); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | function withEnv(key, value, fn) { |
| 58 | const had = Object.prototype.hasOwnProperty.call(process.env, key); |
no test coverage detected