File tree Expand file tree Collapse file tree 1 file changed +7
-11
lines changed Expand file tree Collapse file tree 1 file changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -18,23 +18,19 @@ describe('Platform-detection', function () {
18
18
console . log ( 'Saved env' , npmEnv ) ;
19
19
} ) ;
20
20
21
- // Don't let outer npm_config_* variables leak into a platform test.
22
- beforeEach ( ( ) => {
21
+ function cleanupEnv ( ) {
23
22
for ( const key of npmConfigKeys ( ) ) {
24
23
delete process . env [ key ] ;
25
24
}
26
- } ) ;
25
+ }
26
+
27
+ // Don't let outer npm_config_* variables leak into a platform test.
28
+ beforeEach ( cleanupEnv ) ;
27
29
28
30
// Restore the original config for other test suites.
29
31
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 ) ;
38
34
console . log ( 'Restored env to' , Object . fromEntries (
39
35
npmConfigKeys ( ) . map ( key => [ key , process . env [ key ] ] )
40
36
) ) ;
You can’t perform that action at this time.
0 commit comments