Skip to content

Commit 1c2d176

Browse files
committed
Try a more thorough env recovery
1 parent a6db124 commit 1c2d176

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

test/unit/platform.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,19 @@ describe('Platform-detection', function () {
1818
console.log('Saved env', npmEnv);
1919
});
2020

21-
// Don't let outer npm_config_* variables leak into a platform test.
22-
beforeEach(() => {
21+
function cleanupEnv () {
2322
for (const key of npmConfigKeys()) {
2423
delete process.env[key];
2524
}
26-
});
25+
}
26+
27+
// Don't let outer npm_config_* variables leak into a platform test.
28+
beforeEach(cleanupEnv);
2729

2830
// Restore the original config for other test suites.
2931
after(() => {
30-
for (const key of npmConfigKeys()) {
31-
const value = npmEnv[key];
32-
if (value === undefined) {
33-
delete process.env[key];
34-
} else {
35-
process.env[key] = value;
36-
}
37-
}
32+
cleanupEnv();
33+
Object.assign(process.env, npmEnv);
3834
console.log('Restored env to', Object.fromEntries(
3935
npmConfigKeys().map(key => [key, process.env[key]])
4036
));

0 commit comments

Comments
 (0)