Skip to content

Commit

Permalink
Meta tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jul 19, 2022
1 parent 106d7d8 commit e02a96b
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 29 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ jobs:
fail-fast: false
matrix:
node-version:
- 18
- 16
- 14
os:
- ubuntu-latest
- macos-latest
- windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand Down
14 changes: 7 additions & 7 deletions benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import path from 'node:path';
import process from 'node:process';
import Benchmark from 'benchmark';
import makeDir from 'make-dir';
import tempy from 'tempy';
import {temporaryDirectory} from 'tempy';
import {deleteAsync, deleteSync} from './index.js';

const suite = new Benchmark.Suite('concurrency');

const temporaryDir = tempy.directory();
const temporaryDirectoryPath = temporaryDirectory();

const fixtures = Array.from({length: 2000}, (_, index) => path.resolve(temporaryDir, (index + 1).toString()));
const fixtures = Array.from({length: 2000}, (_, index) => path.resolve(temporaryDirectoryPath, (index + 1).toString()));

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

Expand Down Expand Up @@ -47,7 +47,7 @@ for (const concurrency of concurrencies) {
createFixtures();

const removedFiles = await deleteAsync(['**/*'], {
cwd: temporaryDir,
cwd: temporaryDirectoryPath,
concurrency,
});

Expand All @@ -58,7 +58,7 @@ for (const concurrency of concurrencies) {

console.error(error);

deleteSync(temporaryDir, {cwd: temporaryDir, force: true});
deleteSync(temporaryDirectoryPath, {cwd: temporaryDirectoryPath, force: true});

// eslint-disable-next-line unicorn/no-process-exit
process.exit(1);
Expand All @@ -76,6 +76,6 @@ suite
.on('complete', function () {
console.log(`Fastest is ${this.filter('fastest').map('name')}`);

deleteSync(temporaryDir, {cwd: temporaryDir, force: true});
deleteSync(temporaryDirectoryPath, {cwd: temporaryDirectoryPath, force: true});
})
.run({async: true});
8 changes: 4 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import {GlobbyOptions} from 'globby';
import {Options as GlobbyOptions} from 'globby';

export interface ProgressData {
/**
Deleted files and directories count.
*/
deletedCount: number;
readonly deletedCount: number;

/**
Total files and directories count.
*/
totalCount: number;
readonly totalCount: number;

/**
Completed percentage. A value between `0` and `1`.
*/
percent: number;
readonly percent: number;
}

export interface Options extends GlobbyOptions {
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {promisify} from 'node:util';
import path from 'node:path';
import process from 'node:process';
import globby from 'globby';
import {globby, globbySync} from 'globby';
import isGlob from 'is-glob';
import slash from 'slash';
import gracefulFs from 'graceful-fs';
Expand Down Expand Up @@ -116,7 +116,7 @@ export function deleteSync(patterns, {force, dryRun, cwd = process.cwd(), ...opt

patterns = normalizePatterns(patterns);

const files = globby.sync(patterns, options)
const files = globbySync(patterns, options)
.sort((a, b) => b.localeCompare(a));

const removedFiles = files.map(file => {
Expand Down
25 changes: 15 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
},
"type": "module",
"exports": "./index.js",
"types": "./index.d.ts",
"engines": {
"node": "^14.13.1 || >=16.0.0"
"node": ">=14.16"
},
"scripts": {
"test": "xo && ava --serial --no-worker-threads && tsd",
"test": "xo && ava && tsd",
"bench": "node benchmark.js"
},
"files": [
Expand Down Expand Up @@ -48,21 +49,25 @@
"filesystem"
],
"dependencies": {
"globby": "^11.0.1",
"graceful-fs": "^4.2.4",
"is-glob": "^4.0.1",
"is-path-cwd": "^2.2.0",
"is-path-inside": "^3.0.2",
"p-map": "^4.0.0",
"globby": "^13.1.2",
"graceful-fs": "^4.2.10",
"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": "^3.0.0"
"slash": "^4.0.0"
},
"devDependencies": {
"ava": "^4.3.1",
"benchmark": "^2.1.4",
"make-dir": "^3.1.0",
"tempy": "^0.7.0",
"tempy": "^3.0.0",
"tsd": "^0.22.0",
"xo": "^0.50.0"
},
"ava": {
"serial": true,
"workerThreads": false
}
}
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Similar to [rimraf](https://github.com/isaacs/rimraf), but with a Promise API an

## Install

```
$ npm install del
```sh
npm install del
```

## Usage
Expand Down
4 changes: 2 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';
import test from 'ava';
import tempy from 'tempy';
import {temporaryDirectory} from 'tempy';
import makeDir from 'make-dir';
import {deleteAsync, deleteSync} from './index.js';

Expand Down Expand Up @@ -31,7 +31,7 @@ const fixtures = [
];

test.beforeEach(t => {
t.context.tmp = tempy.directory();
t.context.tmp = temporaryDirectory();

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

0 comments on commit e02a96b

Please sign in to comment.