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

chore: update dependencies and require node 18 #161

Merged
merged 6 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ jobs:
fail-fast: false
matrix:
node-version:
- 22
- 20
- 18
- 16
os:
- ubuntu-latest
- macos-latest
- windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand Down
4 changes: 2 additions & 2 deletions benchmark.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'node:path';
import process from 'node:process';
import Benchmark from 'benchmark';
import makeDir from 'make-dir';
import {makeDirectorySync} from 'make-dir';
pmmmwh marked this conversation as resolved.
Show resolved Hide resolved
import {temporaryDirectory} from 'tempy';
import {deleteAsync, deleteSync} from './index.js';

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

function createFixtures() {
for (const fixture of fixtures) {
makeDir.sync(path.resolve(temporaryDirectoryPath, fixture));
makeDirectorySync(path.resolve(temporaryDirectoryPath, fixture));
}
}

Expand Down
20 changes: 2 additions & 18 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,15 @@
import {promisify} from 'node:util';
import path from 'node:path';
import process from 'node:process';
import {globby, globbySync} from 'globby';
import isGlob from 'is-glob';
import slash from 'slash';
import gracefulFs from 'graceful-fs';
import isPathCwd from 'is-path-cwd';
import isPathInside from 'is-path-inside';
import rimraf from 'rimraf';
import {rimraf} from 'rimraf';
import pMap from 'p-map';
Copy link

@fregante fregante Sep 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think this is needed anymore, right? This has been available since node 14.14

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


const rimrafP = promisify(rimraf);

const rimrafOptions = {
glob: false,
unlink: gracefulFs.unlink,
unlinkSync: gracefulFs.unlinkSync,
chmod: gracefulFs.chmod,
chmodSync: gracefulFs.chmodSync,
stat: gracefulFs.stat,
statSync: gracefulFs.statSync,
lstat: gracefulFs.lstat,
lstatSync: gracefulFs.lstatSync,
rmdir: gracefulFs.rmdir,
rmdirSync: gracefulFs.rmdirSync,
readdir: gracefulFs.readdir,
readdirSync: gracefulFs.readdirSync,
};
Comment on lines -17 to -28
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the support for a custom fs layer in rimraf have long been removed - hence cleaning this up and removing the dependency on graceful-fs in the process.


function safeCheck(file, cwd) {
Expand Down Expand Up @@ -84,7 +68,7 @@ export async function deleteAsync(patterns, {force, dryRun, cwd = process.cwd(),
}

if (!dryRun) {
await rimrafP(file, rimrafOptions);
await rimraf(file, rimrafOptions);
}
sindresorhus marked this conversation as resolved.
Show resolved Hide resolved

deletedCount += 1;
Expand Down
21 changes: 10 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"exports": "./index.js",
"types": "./index.d.ts",
"engines": {
"node": ">=14.16"
"node": ">=18"
sindresorhus marked this conversation as resolved.
Show resolved Hide resolved
},
"scripts": {
"test": "xo && ava && tsd",
Expand Down Expand Up @@ -49,22 +49,21 @@
"filesystem"
],
"dependencies": {
"globby": "^13.1.2",
"graceful-fs": "^4.2.10",
"globby": "^14.0.1",
"is-glob": "^4.0.3",
"is-path-cwd": "^3.0.0",
"is-path-inside": "^4.0.0",
"p-map": "^5.5.0",
"rimraf": "^3.0.2",
"slash": "^4.0.0"
"p-map": "^7.0.2",
"rimraf": "^5.0.7",
"slash": "^5.1.0"
},
"devDependencies": {
"ava": "^4.3.1",
"ava": "^6.1.3",
"benchmark": "^2.1.4",
"make-dir": "^3.1.0",
"tempy": "^3.0.0",
"tsd": "^0.22.0",
"xo": "^0.56.0"
"make-dir": "^5.0.0",
"tempy": "^3.1.0",
"tsd": "^0.31.0",
"xo": "^0.58.0"
},
"ava": {
"serial": true,
Expand Down
28 changes: 16 additions & 12 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import path from 'node:path';
import process from 'node:process';
import test from 'ava';
import {temporaryDirectory} from 'tempy';
import makeDir from 'make-dir';
import {makeDirectorySync} from 'make-dir';
import {deleteAsync, deleteSync} from './index.js';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
Expand Down Expand Up @@ -34,7 +34,7 @@ test.beforeEach(t => {
t.context.tmp = temporaryDirectory();

for (const fixture of fixtures) {
makeDir.sync(path.join(t.context.tmp, fixture));
makeDirectorySync(path.join(t.context.tmp, fixture));
}
});

Expand Down Expand Up @@ -125,7 +125,7 @@ test('does not throw EINVAL - async', async t => {

let count = 0;
while (count !== totalAttempts) {
makeDir.sync(nestedFile);
makeDirectorySync(nestedFile);

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

let count = 0;
while (count !== totalAttempts) {
makeDir.sync(nestedFile);
makeDirectorySync(nestedFile);

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

test('windows can pass relative paths with "\\" - async', async t => {
const nestedFile = path.resolve(t.context.tmp, 'a/b/c/nested.js');
makeDir.sync(nestedFile);
makeDirectorySync(nestedFile);

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

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

test('windows can pass relative paths with "\\" - sync', t => {
const nestedFile = path.resolve(t.context.tmp, 'a/b/c/nested.js');
makeDir.sync(nestedFile);
makeDirectorySync(nestedFile);

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

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

await deleteAsync('non-existent-directory', {onProgress(event) {
report = event;
}});
await deleteAsync('non-existent-directory', {
onProgress(event) {
report = event;
},
});

t.deepEqual(report, {
totalCount: 0,
Expand All @@ -370,9 +372,11 @@ test('onProgress option - progress of non-existent file', async t => {
test('onProgress option - progress of single file', async t => {
let report;

await deleteAsync(t.context.tmp, {cwd: __dirname, force: true, onProgress(event) {
report = event;
}});
await deleteAsync(t.context.tmp, {
cwd: __dirname, force: true, onProgress(event) {
report = event;
},
});

t.deepEqual(report, {
totalCount: 1,
Expand Down
Loading