diff --git a/lib/cli.js b/lib/cli.js index 20f2b67b7..b613666c8 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -5,7 +5,6 @@ import process from 'node:process'; import arrify from 'arrify'; import ciParallelVars from 'ci-parallel-vars'; -import {deleteAsync} from 'del'; import figures from 'figures'; import yargs from 'yargs'; 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 const {nonSemVerExperiments: experiments, projectDir} = conf; if (resetCache) { const cacheDir = path.join(projectDir, 'node_modules', '.cache', 'ava'); - try { - const deletedFilePaths = await deleteAsync('*', {cwd: cacheDir}); + let entries; + try { + entries = fs.readdirSync(cacheDir); + } catch (error) { + if (error.code === 'ENOENT') { + entries = []; + } else { + throw error; + } + } + + for (const entry of entries) { + fs.rmSync(path.join(cacheDir, entry), {recursive: true, force: true}); + } - if (deletedFilePaths.length === 0) { + if (entries.length === 0) { console.log(`\n${chalk.green(figures.tick)} No cache files to remove`); } else { console.log(`\n${chalk.green(figures.tick)} Removed AVA cache files in ${cacheDir}`); diff --git a/package.json b/package.json index 3e5caa15c..9b1d34427 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,6 @@ "concordance": "^5.0.4", "currently-unhandled": "^0.4.1", "debug": "^4.3.4", - "del": "^7.0.0", "emittery": "^1.0.1", "figures": "^5.0.0", "globby": "^13.1.3", diff --git a/test-tap/api.js b/test-tap/api.js index 0d0c271e5..b395d81f8 100644 --- a/test-tap/api.js +++ b/test-tap/api.js @@ -3,7 +3,6 @@ import path from 'node:path'; import {fileURLToPath} from 'node:url'; import ciInfo from 'ci-info'; -import {deleteSync} from 'del'; import {test} from 'tap'; import Api from '../lib/api.js'; @@ -380,7 +379,7 @@ for (const opt of options) { }); test(`caching is enabled by default - workerThreads: ${opt.workerThreads}`, async t => { - deleteSync(path.join(__dirname, 'fixture/caching/node_modules')); + fs.rmSync(path.join(__dirname, 'fixture/caching/node_modules'), {recursive: true, force: true}); const api = await apiCreator({ ...opt, @@ -400,7 +399,7 @@ for (const opt of options) { }); test(`caching can be disabled - workerThreads: ${opt.workerThreads}`, async t => { - deleteSync(path.join(__dirname, 'fixture/caching/node_modules')); + fs.rmSync(path.join(__dirname, 'fixture/caching/node_modules'), {recursive: true, force: true}); const api = await apiCreator({ ...opt,