MCPcopy Create free account
hub / github.com/EvoMap/evolver / withEnv

Function withEnv

test/spawnReplacementProcess.test.js:57–68  ·  view source on GitHub ↗
(key, value, fn)

Source from the content-addressed store, hash-verified

55}
56
57function withEnv(key, value, fn) {
58 const had = Object.prototype.hasOwnProperty.call(process.env, key);
59 const prev = process.env[key];
60 if (value === undefined) delete process.env[key];
61 else process.env[key] = value;
62 try {
63 return fn();
64 } finally {
65 if (had) process.env[key] = prev;
66 else delete process.env[key];
67 }
68}
69
70describe('spawnReplacementProcess on Windows by default', () => {
71 it('returns windows_default_skip without invoking spawn', () => {

Callers 1

Calls 1

fnFunction · 0.70

Tested by

no test coverage detected