Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider replacing del with its dependency rimraf #2952

Closed
live627 opened this issue Jan 23, 2022 · 3 comments
Closed

Consider replacing del with its dependency rimraf #2952

live627 opened this issue Jan 23, 2022 · 3 comments
Labels

Comments

@live627
Copy link
Contributor

live627 commented Jan 23, 2022

The current version of rimraf supports globs, so one could just add an asterisk to the end of the folder, like so:

diff --git a/lib/cli.js b/lib/cli.js
index 3f9974732..d50f08624 100644
--- a/lib/cli.js
+++ b/lib/cli.js
@@ -5,7 +5,7 @@ import process from 'node:process';
 
 import arrify from 'arrify';
 import ciParallelVars from 'ci-parallel-vars';
-import del from 'del';
+import rimraf from 'rimraf';
 import figures from 'figures';
 import yargs from 'yargs';
 import {hideBin} from 'yargs/helpers'; // eslint-disable-line node/file-extension-in-import
@@ -253,7 +253,7 @@ export default async function loadCli() { // eslint-disable-line complexity
 		const cacheDir = path.join(projectDir, 'node_modules', '.cache', 'ava');
 
 		try {
-			const deletedFilePaths = await del('*', {cwd: cacheDir});
+			const deletedFilePaths = rimraf(path.join(cacheDir, '*'));
 
 			if (deletedFilePaths.length === 0) {
 				console.log(`\n${chalk.green(figures.tick)} No cache files to remove`);

--- a/test-tap/api.js
+++ b/test-tap/api.js
@@ -3,7 +3,7 @@ import path from 'node:path';
 import {fileURLToPath} from 'node:url';
 
 import ciInfo from 'ci-info';
-import del from 'del';
+import rimraf from 'rimraf';
 import {test} from 'tap';
 
 import Api from '../lib/api.js';
@@ -400,7 +400,7 @@ for (const opt of options) {
 	});
 
 	test(`caching can be disabled - workerThreads: ${opt.workerThreads}`, async t => {
-		del.sync(path.join(__dirname, 'fixture/caching/node_modules'));
+		rimraf.sync(path.join(__dirname, 'fixture/caching/node_modules'));
 
 		const api = await apiCreator({
 			...opt,

Could this be simplified?

[email protected] (44 deps, 809.26kb, 342 files)
├─┬ [email protected] (23 deps, 576.5kb, 238 files)
│ ├── [email protected] (3.09kb, 5 files)
│ ├─┬ [email protected] (1 dep, 10.57kb, 9 files)
│ │ ╰── [email protected] (5.28kb, 5 files)
│ ├─┬ [email protected] (17 deps, 490.43kb, 206 files)
│ │ ├── @nodelib/[email protected] (11.57kb, 15 files)
│ │ ├─┬ @nodelib/[email protected] (6 deps, 120.09kb, 96 files)
│ │ │ ├─┬ @nodelib/[email protected] (3 deps, 47.78kb, 47 files)
│ │ │ │ ├── @nodelib/[email protected] (🔗, 11.57kb, 15 files)
│ │ │ │ ╰─┬ [email protected] (1 dep, 14.58kb, 9 files)
│ │ │ │   ╰── [email protected] (8.17kb, 5 files)
│ │ │ ╰─┬ [email protected] (1 dep, 46.54kb, 24 files)
│ │ │   ╰── [email protected] (9.22kb, 10 files)
│ │ ├─┬ [email protected] (2 deps, 31.21kb, 13 files)
│ │ │ ╰── [email protected] (🔗, 1 dep, 19.36kb, 8 files)
│ │ ├── [email protected] (🔗, 8.69kb, 4 files)
│ │ ╰─┬ [email protected] (5 deps, 243.77kb, 38 files)
│ │   ├─┬ [email protected] (3 deps, 95.84kb, 23 files)
│ │   │ ╰─┬ [email protected] (2 deps, 47.76kb, 12 files)
│ │   │   ╰─┬ [email protected] (1 dep, 31.79kb, 8 files)
│ │   │     ╰── [email protected] (9.39kb, 4 files)
│ │   ╰── [email protected] (87.84kb, 10 files)
│ ├── [email protected] (47.72kb, 6 files)
│ ├── [email protected] (8.69kb, 4 files)
│ ╰── [email protected] (🔗, 3.42kb, 5 files)
├── [email protected] (30.86kb, 7 files)
├─┬ [email protected] (1 dep, 19.36kb, 8 files)
│ ╰── [email protected] (6.07kb, 4 files)
├── [email protected] (2.7kb, 5 files)
├── [email protected] (4.02kb, 5 files)
├─┬ [email protected] (3 deps, 24.69kb, 20 files)
│ ╰─┬ [email protected] (2 deps, 16.21kb, 15 files)
│   ├── [email protected] (5.38kb, 5 files)
│   ╰── [email protected] (4.29kb, 5 files)
├─┬ [email protected] (12 deps, 158.96kb, 62 files)
│ ╰─┬ [email protected] (11 deps, 142.04kb, 56 files)
│   ├── [email protected] (13.12kb, 5 files)
│   ├─┬ [email protected] (3 deps, 13.41kb, 16 files)
│   │ ├── [email protected] (🔗, 1 dep, 6.84kb, 8 files)
│   │ ╰── [email protected] (2.89kb, 4 files)
│   ├── [email protected] (3.87kb, 5 files)
│   ├─┬ [email protected] (3 deps, 54.66kb, 20 files)
│   │ ╰─┬ [email protected] (2 deps, 22.32kb, 16 files)
│   │   ├── [email protected] (6.78kb, 5 files)
│   │   ╰── [email protected] (4.75kb, 7 files)
│   ├─┬ [email protected] (1 dep, 6.84kb, 8 files)
│   │ ╰── [email protected] (2.89kb, 4 files)
│   ╰── [email protected] (3.53kb, 4 files)
╰── [email protected] (3.42kb, 5 files)

I already have a commit lined up.

@live627
Copy link
Contributor Author

live627 commented Jan 23, 2022

From https://stackoverflow.com/a/57866165/4710434

recursive rmdir uses rimraf internally as can be seen in pull request nodejs/node/pull/29168

fs.rm(dir, { recursive: true, force: true });

Added in: v14.14.0

@sindresorhus
Copy link
Member

I think it's better to just wait until AVA can target Node.js 14 and use the native fs.rm method with recursive option.

@novemberborn
Copy link
Member

That'll be in a few months time actually.

We don't tend to keep issues open for this purpose though so I'll close for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants