@@ -6,26 +6,26 @@ const { promisify } = require('util')
6
6
const mkdirp = require ( 'mkdirp-infer-owner' )
7
7
const npmlog = require ( 'npmlog' )
8
8
const rimraf = promisify ( require ( 'rimraf' ) )
9
- const t = require ( 'tap' )
10
9
11
- let active = null
12
10
const chain = new Map ( )
13
11
const sandboxes = new Map ( )
14
12
13
+ // Disable lint errors for assigning to process global
14
+ /* global process:writable */
15
+
15
16
// keep a reference to the real process
16
17
const _process = process
17
18
18
- const processHook = createHook ( {
19
+ createHook ( {
19
20
init : ( asyncId , type , triggerAsyncId , resource ) => {
20
21
// track parentage of asyncIds
21
22
chain . set ( asyncId , triggerAsyncId )
22
23
} ,
23
24
before : ( asyncId ) => {
24
25
// find the nearest parent id that has a sandbox
25
26
let parent = asyncId
26
- while ( chain . has ( parent ) && ! sandboxes . has ( parent ) ) {
27
+ while ( chain . has ( parent ) && ! sandboxes . has ( parent ) )
27
28
parent = chain . get ( parent )
28
- }
29
29
30
30
process = sandboxes . has ( parent )
31
31
? sandboxes . get ( parent )
@@ -173,7 +173,7 @@ class Sandbox extends EventEmitter {
173
173
if ( this [ _npm ] ) {
174
174
// replace default config values with placeholders
175
175
for ( const name of redactedDefaults ) {
176
- let value = this [ _npm ] . config . defaults [ name ]
176
+ const value = this [ _npm ] . config . defaults [ name ]
177
177
clean = clean . split ( value ) . join ( `{${ name . toUpperCase ( ) } }` )
178
178
}
179
179
@@ -201,21 +201,19 @@ class Sandbox extends EventEmitter {
201
201
202
202
// test.teardown hook
203
203
teardown ( ) {
204
- if ( this [ _parent ] ) {
204
+ if ( this [ _parent ] )
205
205
sandboxes . delete ( this [ _parent ] )
206
- }
206
+
207
207
return rimraf ( this [ _dirs ] . temp ) . catch ( ( ) => null )
208
208
}
209
209
210
210
// proxy get handler
211
211
[ _get ] ( target , prop , receiver ) {
212
- if ( this [ _data ] . has ( prop ) ) {
212
+ if ( this [ _data ] . has ( prop ) )
213
213
return this [ _data ] . get ( prop )
214
- }
215
214
216
- if ( this [ prop ] !== undefined ) {
215
+ if ( this [ prop ] !== undefined )
217
216
return Reflect . get ( this , prop , this )
218
- }
219
217
220
218
const actual = Reflect . get ( target , prop , receiver )
221
219
if ( typeof actual === 'function' ) {
0 commit comments