@@ -2,15 +2,17 @@ const t = require('tap')
2
2
const { parse, basename, relative } = require ( 'path' )
3
3
const { statSync } = require ( 'fs' )
4
4
t . formatSnapshot = calls =>
5
- calls . map ( args =>
6
- args . map ( arg =>
7
- String ( arg )
8
- . split ( process . cwd ( ) )
9
- . join ( '{CWD}' )
10
- . replace ( / \\ / g, '/' )
11
- . replace ( / .* \/ ( \. [ a - z ] \. ) [ ^ / ] * $ / , '{tmpfile}' )
12
- )
13
- )
5
+ Array . isArray ( calls )
6
+ ? calls . map ( args =>
7
+ args . map ( arg =>
8
+ String ( arg )
9
+ . split ( process . cwd ( ) )
10
+ . join ( '{CWD}' )
11
+ . replace ( / \\ / g, '/' )
12
+ . replace ( / .* \/ ( \. [ a - z ] \. ) [ ^ / ] * $ / , '{tmpfile}' )
13
+ )
14
+ )
15
+ : calls
14
16
15
17
const fixture = {
16
18
a : 'a' ,
@@ -310,14 +312,14 @@ t.test('handle EPERMs on unlink by trying to chmod 0o666', async t => {
310
312
// nest it so that we clean up the mess
311
313
const path = t . testdir ( { test : fixture } ) + '/test'
312
314
rimrafWindowsSync ( path , { } )
313
- t . matchSnapshot ( CHMODS )
315
+ t . matchSnapshot ( CHMODS . length , 'chmods' )
314
316
t . end ( )
315
317
} )
316
318
t . test ( 'async' , async t => {
317
319
// nest it so that we clean up the mess
318
320
const path = t . testdir ( { test : fixture } ) + '/test'
319
321
await rimrafWindows ( path , { } )
320
- t . matchSnapshot ( CHMODS )
322
+ t . matchSnapshot ( CHMODS . length , 'chmods' )
321
323
t . end ( )
322
324
} )
323
325
t . end ( )
@@ -374,14 +376,14 @@ t.test('handle EPERMs, chmod returns ENOENT', async t => {
374
376
// nest it so that we clean up the mess
375
377
const path = t . testdir ( { test : fixture } ) + '/test'
376
378
rimrafWindowsSync ( path , { } )
377
- t . matchSnapshot ( CHMODS )
379
+ t . matchSnapshot ( CHMODS . length , 'chmods' )
378
380
t . end ( )
379
381
} )
380
382
t . test ( 'async' , async t => {
381
383
// nest it so that we clean up the mess
382
384
const path = t . testdir ( { test : fixture } ) + '/test'
383
385
await rimrafWindows ( path , { } )
384
- t . matchSnapshot ( CHMODS )
386
+ t . matchSnapshot ( CHMODS . length , 'chmods' )
385
387
t . end ( )
386
388
} )
387
389
t . end ( )
@@ -438,14 +440,14 @@ t.test('handle EPERMs, chmod raises something other than ENOENT', async t => {
438
440
// nest it so that we clean up the mess
439
441
const path = t . testdir ( { test : fixture } ) + '/test'
440
442
t . throws ( ( ) => rimrafWindowsSync ( path , { } ) , { code : 'EPERM' } )
441
- t . matchSnapshot ( CHMODS )
443
+ t . matchSnapshot ( CHMODS . length , 'chmods' )
442
444
t . end ( )
443
445
} )
444
446
t . test ( 'async' , async t => {
445
447
// nest it so that we clean up the mess
446
448
const path = t . testdir ( { test : fixture } ) + '/test'
447
449
t . rejects ( rimrafWindows ( path , { } ) , { code : 'EPERM' } )
448
- t . matchSnapshot ( CHMODS )
450
+ t . matchSnapshot ( CHMODS . length , 'chmods' )
449
451
t . end ( )
450
452
} )
451
453
t . end ( )
0 commit comments