1
- import { fileURLToPath } from 'node:url' ;
2
1
import fs from 'node:fs' ;
3
2
import path from 'node:path' ;
4
3
import process from 'node:process' ;
4
+ import { fileURLToPath } from 'node:url' ;
5
5
import test from 'ava' ;
6
6
import { temporaryDirectory } from 'tempy' ;
7
- import makeDir from 'make-dir' ;
8
7
import { deleteAsync , deleteSync } from './index.js' ;
9
8
10
9
const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
@@ -34,7 +33,7 @@ test.beforeEach(t => {
34
33
t . context . tmp = temporaryDirectory ( ) ;
35
34
36
35
for ( const fixture of fixtures ) {
37
- makeDir . sync ( path . join ( t . context . tmp , fixture ) ) ;
36
+ fs . mkdirSync ( path . join ( t . context . tmp , fixture ) , { recursive : true } ) ;
38
37
}
39
38
} ) ;
40
39
@@ -125,7 +124,7 @@ test('does not throw EINVAL - async', async t => {
125
124
126
125
let count = 0 ;
127
126
while ( count !== totalAttempts ) {
128
- makeDir . sync ( nestedFile ) ;
127
+ fs . mkdirSync ( nestedFile , { recursive : true } ) ;
129
128
130
129
// eslint-disable-next-line no-await-in-loop
131
130
const removed = await deleteAsync ( '**/*' , {
@@ -160,7 +159,7 @@ test('does not throw EINVAL - sync', t => {
160
159
161
160
let count = 0 ;
162
161
while ( count !== totalAttempts ) {
163
- makeDir . sync ( nestedFile ) ;
162
+ fs . mkdirSync ( nestedFile , { recursive : true } ) ;
164
163
165
164
const removed = deleteSync ( '**/*' , {
166
165
cwd : t . context . tmp ,
@@ -337,7 +336,7 @@ test('windows can pass absolute paths with "\\" - sync', t => {
337
336
338
337
test ( 'windows can pass relative paths with "\\" - async' , async t => {
339
338
const nestedFile = path . resolve ( t . context . tmp , 'a/b/c/nested.js' ) ;
340
- makeDir . sync ( nestedFile ) ;
339
+ fs . mkdirSync ( nestedFile , { recursive : true } ) ;
341
340
342
341
const removeFiles = await deleteAsync ( [ nestedFile ] , { cwd : t . context . tmp , dryRun : true } ) ;
343
342
@@ -346,7 +345,7 @@ test('windows can pass relative paths with "\\" - async', async t => {
346
345
347
346
test ( 'windows can pass relative paths with "\\" - sync' , t => {
348
347
const nestedFile = path . resolve ( t . context . tmp , 'a/b/c/nested.js' ) ;
349
- makeDir . sync ( nestedFile ) ;
348
+ fs . mkdirSync ( nestedFile , { recursive : true } ) ;
350
349
351
350
const removeFiles = deleteSync ( [ nestedFile ] , { cwd : t . context . tmp , dryRun : true } ) ;
352
351
@@ -356,9 +355,11 @@ test('windows can pass relative paths with "\\" - sync', t => {
356
355
test ( 'onProgress option - progress of non-existent file' , async t => {
357
356
let report ;
358
357
359
- await deleteAsync ( 'non-existent-directory' , { onProgress ( event ) {
360
- report = event ;
361
- } } ) ;
358
+ await deleteAsync ( 'non-existent-directory' , {
359
+ onProgress ( event ) {
360
+ report = event ;
361
+ } ,
362
+ } ) ;
362
363
363
364
t . deepEqual ( report , {
364
365
totalCount : 0 ,
@@ -370,9 +371,11 @@ test('onProgress option - progress of non-existent file', async t => {
370
371
test ( 'onProgress option - progress of single file' , async t => {
371
372
let report ;
372
373
373
- await deleteAsync ( t . context . tmp , { cwd : __dirname , force : true , onProgress ( event ) {
374
- report = event ;
375
- } } ) ;
374
+ await deleteAsync ( t . context . tmp , {
375
+ cwd : __dirname , force : true , onProgress ( event ) {
376
+ report = event ;
377
+ } ,
378
+ } ) ;
376
379
377
380
t . deepEqual ( report , {
378
381
totalCount : 1 ,
@@ -385,7 +388,7 @@ test('onProgress option - progress of single file', async t => {
385
388
test ( 'onProgress option - progress of multiple files' , async t => {
386
389
const reports = [ ] ;
387
390
388
- const sourcePath = process . platform === 'win32' ? path . resolve ( `${ t . context . tmp } /*` ) . replace ( / \\ / g , '/' ) : `${ t . context . tmp } /*` ;
391
+ const sourcePath = process . platform === 'win32' ? path . resolve ( `${ t . context . tmp } /*` ) . replaceAll ( '\\' , '/' ) : `${ t . context . tmp } /*` ;
389
392
390
393
await deleteAsync ( sourcePath , {
391
394
cwd : __dirname ,
0 commit comments