Skip to content

Commit e2e5b71

Browse files
pmmmwhsindresorhus
andcommittedOct 7, 2024
Require Node.js 18 and update dependencies (#161)
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
1 parent 7df7949 commit e2e5b71

File tree

5 files changed

+36
-59
lines changed

5 files changed

+36
-59
lines changed
 

‎.github/workflows/main.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
node-version:
13+
- 22
1314
- 20
1415
- 18
15-
- 16
1616
os:
1717
- ubuntu-latest
1818
- macos-latest
1919
- windows-latest
2020
steps:
21-
- uses: actions/checkout@v3
22-
- uses: actions/setup-node@v3
21+
- uses: actions/checkout@v4
22+
- uses: actions/setup-node@v4
2323
with:
2424
node-version: ${{ matrix.node-version }}
2525
- run: npm install

‎benchmark.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import fs from 'node:fs';
12
import path from 'node:path';
23
import process from 'node:process';
34
import Benchmark from 'benchmark';
4-
import makeDir from 'make-dir';
55
import {temporaryDirectory} from 'tempy';
66
import {deleteAsync, deleteSync} from './index.js';
77

@@ -13,7 +13,7 @@ const fixtures = Array.from({length: 2000}, (_, index) => path.resolve(temporary
1313

1414
function createFixtures() {
1515
for (const fixture of fixtures) {
16-
makeDir.sync(path.resolve(temporaryDirectoryPath, fixture));
16+
fs.mkdirSync(path.resolve(temporaryDirectoryPath, fixture), {recursive: true});
1717
}
1818
}
1919

‎index.js

+5-24
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,13 @@
1-
import {promisify} from 'node:util';
1+
import fs from 'node:fs';
2+
import fsPromises from 'node:fs/promises';
23
import path from 'node:path';
34
import process from 'node:process';
45
import {globby, globbySync} from 'globby';
56
import isGlob from 'is-glob';
6-
import slash from 'slash';
7-
import gracefulFs from 'graceful-fs';
87
import isPathCwd from 'is-path-cwd';
98
import isPathInside from 'is-path-inside';
10-
import rimraf from 'rimraf';
119
import pMap from 'p-map';
12-
13-
const rimrafP = promisify(rimraf);
14-
15-
const rimrafOptions = {
16-
glob: false,
17-
unlink: gracefulFs.unlink,
18-
unlinkSync: gracefulFs.unlinkSync,
19-
chmod: gracefulFs.chmod,
20-
chmodSync: gracefulFs.chmodSync,
21-
stat: gracefulFs.stat,
22-
statSync: gracefulFs.statSync,
23-
lstat: gracefulFs.lstat,
24-
lstatSync: gracefulFs.lstatSync,
25-
rmdir: gracefulFs.rmdir,
26-
rmdirSync: gracefulFs.rmdirSync,
27-
readdir: gracefulFs.readdir,
28-
readdirSync: gracefulFs.readdirSync,
29-
};
10+
import slash from 'slash';
3011

3112
function safeCheck(file, cwd) {
3213
if (isPathCwd(file)) {
@@ -84,7 +65,7 @@ export async function deleteAsync(patterns, {force, dryRun, cwd = process.cwd(),
8465
}
8566

8667
if (!dryRun) {
87-
await rimrafP(file, rimrafOptions);
68+
await fsPromises.rm(file, {recursive: true, force: true});
8869
}
8970

9071
deletedCount += 1;
@@ -128,7 +109,7 @@ export function deleteSync(patterns, {force, dryRun, cwd = process.cwd(), ...opt
128109
}
129110

130111
if (!dryRun) {
131-
rimraf.sync(file, rimrafOptions);
112+
fs.rmSync(file, {recursive: true, force: true});
132113
}
133114

134115
return file;

‎package.json

+9-16
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"exports": "./index.js",
1515
"types": "./index.d.ts",
1616
"engines": {
17-
"node": ">=14.16"
17+
"node": ">=18"
1818
},
1919
"scripts": {
2020
"test": "xo && ava && tsd",
@@ -49,30 +49,23 @@
4949
"filesystem"
5050
],
5151
"dependencies": {
52-
"globby": "^13.1.2",
53-
"graceful-fs": "^4.2.10",
52+
"globby": "^14.0.1",
5453
"is-glob": "^4.0.3",
5554
"is-path-cwd": "^3.0.0",
5655
"is-path-inside": "^4.0.0",
57-
"p-map": "^5.5.0",
58-
"rimraf": "^3.0.2",
59-
"slash": "^4.0.0"
56+
"p-map": "^7.0.2",
57+
"rimraf": "^5.0.7",
58+
"slash": "^5.1.0"
6059
},
6160
"devDependencies": {
62-
"ava": "^4.3.1",
61+
"ava": "^6.1.3",
6362
"benchmark": "^2.1.4",
64-
"make-dir": "^3.1.0",
65-
"tempy": "^3.0.0",
66-
"tsd": "^0.22.0",
67-
"xo": "^0.56.0"
63+
"tempy": "^3.1.0",
64+
"tsd": "^0.31.0",
65+
"xo": "^0.58.0"
6866
},
6967
"ava": {
7068
"serial": true,
7169
"workerThreads": false
72-
},
73-
"xo": {
74-
"rules": {
75-
"unicorn/prefer-string-replace-all": "off"
76-
}
7770
}
7871
}

‎test.js

+17-14
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import {fileURLToPath} from 'node:url';
21
import fs from 'node:fs';
32
import path from 'node:path';
43
import process from 'node:process';
4+
import {fileURLToPath} from 'node:url';
55
import test from 'ava';
66
import {temporaryDirectory} from 'tempy';
7-
import makeDir from 'make-dir';
87
import {deleteAsync, deleteSync} from './index.js';
98

109
const __dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -34,7 +33,7 @@ test.beforeEach(t => {
3433
t.context.tmp = temporaryDirectory();
3534

3635
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});
3837
}
3938
});
4039

@@ -125,7 +124,7 @@ test('does not throw EINVAL - async', async t => {
125124

126125
let count = 0;
127126
while (count !== totalAttempts) {
128-
makeDir.sync(nestedFile);
127+
fs.mkdirSync(nestedFile, {recursive: true});
129128

130129
// eslint-disable-next-line no-await-in-loop
131130
const removed = await deleteAsync('**/*', {
@@ -160,7 +159,7 @@ test('does not throw EINVAL - sync', t => {
160159

161160
let count = 0;
162161
while (count !== totalAttempts) {
163-
makeDir.sync(nestedFile);
162+
fs.mkdirSync(nestedFile, {recursive: true});
164163

165164
const removed = deleteSync('**/*', {
166165
cwd: t.context.tmp,
@@ -337,7 +336,7 @@ test('windows can pass absolute paths with "\\" - sync', t => {
337336

338337
test('windows can pass relative paths with "\\" - async', async t => {
339338
const nestedFile = path.resolve(t.context.tmp, 'a/b/c/nested.js');
340-
makeDir.sync(nestedFile);
339+
fs.mkdirSync(nestedFile, {recursive: true});
341340

342341
const removeFiles = await deleteAsync([nestedFile], {cwd: t.context.tmp, dryRun: true});
343342

@@ -346,7 +345,7 @@ test('windows can pass relative paths with "\\" - async', async t => {
346345

347346
test('windows can pass relative paths with "\\" - sync', t => {
348347
const nestedFile = path.resolve(t.context.tmp, 'a/b/c/nested.js');
349-
makeDir.sync(nestedFile);
348+
fs.mkdirSync(nestedFile, {recursive: true});
350349

351350
const removeFiles = deleteSync([nestedFile], {cwd: t.context.tmp, dryRun: true});
352351

@@ -356,9 +355,11 @@ test('windows can pass relative paths with "\\" - sync', t => {
356355
test('onProgress option - progress of non-existent file', async t => {
357356
let report;
358357

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+
});
362363

363364
t.deepEqual(report, {
364365
totalCount: 0,
@@ -370,9 +371,11 @@ test('onProgress option - progress of non-existent file', async t => {
370371
test('onProgress option - progress of single file', async t => {
371372
let report;
372373

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+
});
376379

377380
t.deepEqual(report, {
378381
totalCount: 1,
@@ -385,7 +388,7 @@ test('onProgress option - progress of single file', async t => {
385388
test('onProgress option - progress of multiple files', async t => {
386389
const reports = [];
387390

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}/*`;
389392

390393
await deleteAsync(sourcePath, {
391394
cwd: __dirname,

0 commit comments

Comments
 (0)
Please sign in to comment.