Skip to content

Commit 612ac0e

Browse files
committed
Copy properties back onto process.env rather than overwriting it
Copy the properties rather than directly overwriting `process.env` to preserve behaviour like aliasing `process.env.PATH` with `process.env.Path` on Windows.
1 parent c4e8011 commit 612ac0e

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

lib/testing-utils.js

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/testing-utils.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/testing-utils.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,13 @@ export function setupTests(test: TestFn<any>) {
8383
sinon.restore();
8484

8585
// Undo any modifications to the env
86-
process.env = t.context.env;
86+
// Copy the properties rather than directly overwriting `process.env` to
87+
// preserve behaviour like aliasing `process.env.PATH` with
88+
// `process.env.Path` on Windows.
89+
for (const key of Object.keys(process.env)) {
90+
delete process.env[key];
91+
}
92+
Object.assign(process.env, t.context.env);
8793
});
8894
}
8995

0 commit comments

Comments
 (0)