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 all commits
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 fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';
import Benchmark from 'benchmark';
import makeDir from 'make-dir';
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));
fs.mkdirSync(path.resolve(temporaryDirectoryPath, fixture), {recursive: true});
}
}

Expand Down
29 changes: 5 additions & 24 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,13 @@
import {promisify} from 'node:util';
import fs from 'node:fs';
import fsPromises from 'node:fs/promises';
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 pMap from 'p-map';

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.

};
import slash from 'slash';

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

if (!dryRun) {
await rimrafP(file, rimrafOptions);
await fsPromises.rm(file, {recursive: true, force: true});
}

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

if (!dryRun) {
rimraf.sync(file, rimrafOptions);
fs.rmSync(file, {recursive: true, force: true});
}

return file;
Expand Down
25 changes: 9 additions & 16 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,30 +49,23 @@
"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"
"tempy": "^3.1.0",
"tsd": "^0.31.0",
"xo": "^0.58.0"
},
"ava": {
"serial": true,
"workerThreads": false
},
"xo": {
"rules": {
"unicorn/prefer-string-replace-all": "off"
}
}
}
31 changes: 17 additions & 14 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import {fileURLToPath} from 'node:url';
import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';
import {fileURLToPath} from 'node:url';
import test from 'ava';
import {temporaryDirectory} from 'tempy';
import makeDir from 'make-dir';
import {deleteAsync, deleteSync} from './index.js';

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

for (const fixture of fixtures) {
makeDir.sync(path.join(t.context.tmp, fixture));
fs.mkdirSync(path.join(t.context.tmp, fixture), {recursive: true});
}
});

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

let count = 0;
while (count !== totalAttempts) {
makeDir.sync(nestedFile);
fs.mkdirSync(nestedFile, {recursive: true});

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

let count = 0;
while (count !== totalAttempts) {
makeDir.sync(nestedFile);
fs.mkdirSync(nestedFile, {recursive: true});

const removed = deleteSync('**/*', {
cwd: t.context.tmp,
Expand Down Expand Up @@ -337,7 +336,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);
fs.mkdirSync(nestedFile, {recursive: true});

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

Expand All @@ -346,7 +345,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);
fs.mkdirSync(nestedFile, {recursive: true});

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

Expand All @@ -356,9 +355,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 +371,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 All @@ -385,7 +388,7 @@ test('onProgress option - progress of single file', async t => {
test('onProgress option - progress of multiple files', async t => {
const reports = [];

const sourcePath = process.platform === 'win32' ? path.resolve(`${t.context.tmp}/*`).replace(/\\/g, '/') : `${t.context.tmp}/*`;
const sourcePath = process.platform === 'win32' ? path.resolve(`${t.context.tmp}/*`).replaceAll('\\', '/') : `${t.context.tmp}/*`;

await deleteAsync(sourcePath, {
cwd: __dirname,
Expand Down