Skip to content

Commit faa9654

Browse files
Replace 'del' dependency by built-in recursive fs.rm (#3198)
Co-authored-by: Mark Wubben <[email protected]>
1 parent d7c6120 commit faa9654

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

lib/cli.js

+15-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import process from 'node:process';
55

66
import arrify from 'arrify';
77
import ciParallelVars from 'ci-parallel-vars';
8-
import {deleteAsync} from 'del';
98
import figures from 'figures';
109
import yargs from 'yargs';
1110
import {hideBin} from 'yargs/helpers'; // eslint-disable-line n/file-extension-in-import
@@ -261,11 +260,23 @@ export default async function loadCli() { // eslint-disable-line complexity
261260
const {nonSemVerExperiments: experiments, projectDir} = conf;
262261
if (resetCache) {
263262
const cacheDir = path.join(projectDir, 'node_modules', '.cache', 'ava');
264-
265263
try {
266-
const deletedFilePaths = await deleteAsync('*', {cwd: cacheDir});
264+
let entries;
265+
try {
266+
entries = fs.readdirSync(cacheDir);
267+
} catch (error) {
268+
if (error.code === 'ENOENT') {
269+
entries = [];
270+
} else {
271+
throw error;
272+
}
273+
}
274+
275+
for (const entry of entries) {
276+
fs.rmSync(path.join(cacheDir, entry), {recursive: true, force: true});
277+
}
267278

268-
if (deletedFilePaths.length === 0) {
279+
if (entries.length === 0) {
269280
console.log(`\n${chalk.green(figures.tick)} No cache files to remove`);
270281
} else {
271282
console.log(`\n${chalk.green(figures.tick)} Removed AVA cache files in ${cacheDir}`);

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@
100100
"concordance": "^5.0.4",
101101
"currently-unhandled": "^0.4.1",
102102
"debug": "^4.3.4",
103-
"del": "^7.0.0",
104103
"emittery": "^1.0.1",
105104
"figures": "^5.0.0",
106105
"globby": "^13.1.3",

test-tap/api.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import path from 'node:path';
33
import {fileURLToPath} from 'node:url';
44

55
import ciInfo from 'ci-info';
6-
import {deleteSync} from 'del';
76
import {test} from 'tap';
87

98
import Api from '../lib/api.js';
@@ -380,7 +379,7 @@ for (const opt of options) {
380379
});
381380

382381
test(`caching is enabled by default - workerThreads: ${opt.workerThreads}`, async t => {
383-
deleteSync(path.join(__dirname, 'fixture/caching/node_modules'));
382+
fs.rmSync(path.join(__dirname, 'fixture/caching/node_modules'), {recursive: true, force: true});
384383

385384
const api = await apiCreator({
386385
...opt,
@@ -400,7 +399,7 @@ for (const opt of options) {
400399
});
401400

402401
test(`caching can be disabled - workerThreads: ${opt.workerThreads}`, async t => {
403-
deleteSync(path.join(__dirname, 'fixture/caching/node_modules'));
402+
fs.rmSync(path.join(__dirname, 'fixture/caching/node_modules'), {recursive: true, force: true});
404403

405404
const api = await apiCreator({
406405
...opt,

0 commit comments

Comments
 (0)