+81
-91
@@ -1,116 +0,106 @@ | ||
| import {GlobbyOptions} from 'globby'; | ||
| import {Options as GlobbyOptions} from 'globby'; | ||
| declare namespace del { | ||
| interface ProgressData { | ||
| /** | ||
| Deleted files and directories count. | ||
| */ | ||
| deletedCount: number; | ||
| export interface ProgressData { | ||
| /** | ||
| Deleted files and directories count. | ||
| */ | ||
| readonly deletedCount: number; | ||
| /** | ||
| Total files and directories count. | ||
| */ | ||
| totalCount: number; | ||
| /** | ||
| Total files and directories count. | ||
| */ | ||
| readonly totalCount: number; | ||
| /** | ||
| Completed percentage. A value between `0` and `1`. | ||
| */ | ||
| percent: number; | ||
| } | ||
| /** | ||
| Completed percentage. A value between `0` and `1`. | ||
| */ | ||
| readonly percent: number; | ||
| } | ||
| interface Options extends GlobbyOptions { | ||
| /** | ||
| Allow deleting the current working directory and outside. | ||
| export interface Options extends GlobbyOptions { | ||
| /** | ||
| Allow deleting the current working directory and outside. | ||
| @default false | ||
| */ | ||
| readonly force?: boolean; | ||
| @default false | ||
| */ | ||
| readonly force?: boolean; | ||
| /** | ||
| See what would be deleted. | ||
| /** | ||
| See what would be deleted. | ||
| @default false | ||
| @default false | ||
| @example | ||
| ``` | ||
| import del = require('del'); | ||
| @example | ||
| ``` | ||
| import {deleteAsync} from 'del'; | ||
| (async () => { | ||
| const deletedPaths = await del(['temp/*.js'], {dryRun: true}); | ||
| const deletedPaths = await deleteAsync(['temp/*.js'], {dryRun: true}); | ||
| console.log('Files and directories that would be deleted:\n', deletedPaths.join('\n')); | ||
| })(); | ||
| ``` | ||
| */ | ||
| readonly dryRun?: boolean; | ||
| console.log('Files and directories that would be deleted:\n', deletedPaths.join('\n')); | ||
| ``` | ||
| */ | ||
| readonly dryRun?: boolean; | ||
| /** | ||
| Concurrency limit. Minimum: `1`. | ||
| /** | ||
| Concurrency limit. Minimum: `1`. | ||
| @default Infinity | ||
| */ | ||
| readonly concurrency?: number; | ||
| @default Infinity | ||
| */ | ||
| readonly concurrency?: number; | ||
| /** | ||
| Called after each file or directory is deleted. | ||
| /** | ||
| Called after each file or directory is deleted. | ||
| @example | ||
| ``` | ||
| import del from 'del'; | ||
| @example | ||
| ``` | ||
| import {deleteAsync} from 'del'; | ||
| await del(patterns, { | ||
| onProgress: progress => { | ||
| // … | ||
| }}); | ||
| ``` | ||
| */ | ||
| readonly onProgress?: (progress: ProgressData) => void; | ||
| } | ||
| await deleteAsync(patterns, { | ||
| onProgress: progress => { | ||
| // … | ||
| }}); | ||
| ``` | ||
| */ | ||
| readonly onProgress?: (progress: ProgressData) => void; | ||
| } | ||
| declare const del: { | ||
| /** | ||
| Synchronously delete files and directories using glob patterns. | ||
| /** | ||
| Delete files and directories using glob patterns. | ||
| Note that glob patterns can only contain forward-slashes, not backward-slashes. Windows file paths can use backward-slashes as long as the path does not contain any glob-like characters, otherwise use `path.posix.join()` instead of `path.join()`. | ||
| Note that glob patterns can only contain forward-slashes, not backward-slashes. Windows file paths can use backward-slashes as long as the path does not contain any glob-like characters, otherwise use `path.posix.join()` instead of `path.join()`. | ||
| @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns). | ||
| - [Pattern examples with expected matches](https://github.com/sindresorhus/multimatch/blob/main/test/test.js) | ||
| - [Quick globbing pattern overview](https://github.com/sindresorhus/multimatch#globbing-patterns) | ||
| @param options - You can specify any of the [`globby` options](https://github.com/sindresorhus/globby#options) in addition to the `del` options. In contrast to the `globby` defaults, `expandDirectories`, `onlyFiles`, and `followSymbolicLinks` are `false` by default. | ||
| @returns The deleted paths. | ||
| */ | ||
| sync: ( | ||
| patterns: string | readonly string[], | ||
| options?: del.Options | ||
| ) => string[]; | ||
| @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns). | ||
| - [Pattern examples with expected matches](https://github.com/sindresorhus/multimatch/blob/main/test/test.js) | ||
| - [Quick globbing pattern overview](https://github.com/sindresorhus/multimatch#globbing-patterns) | ||
| @param options - You can specify any of the [`globby` options](https://github.com/sindresorhus/globby#options) in addition to the `del` options. In contrast to the `globby` defaults, `expandDirectories`, `onlyFiles`, and `followSymbolicLinks` are `false` by default. | ||
| @returns The deleted paths. | ||
| /** | ||
| Delete files and directories using glob patterns. | ||
| @example | ||
| ``` | ||
| import {deleteAsync} from 'del'; | ||
| Note that glob patterns can only contain forward-slashes, not backward-slashes. Windows file paths can use backward-slashes as long as the path does not contain any glob-like characters, otherwise use `path.posix.join()` instead of `path.join()`. | ||
| const deletedPaths = await deleteAsync(['temp/*.js', '!temp/unicorn.js']); | ||
| @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns). | ||
| - [Pattern examples with expected matches](https://github.com/sindresorhus/multimatch/blob/main/test/test.js) | ||
| - [Quick globbing pattern overview](https://github.com/sindresorhus/multimatch#globbing-patterns) | ||
| @param options - You can specify any of the [`globby` options](https://github.com/sindresorhus/globby#options) in addition to the `del` options. In contrast to the `globby` defaults, `expandDirectories`, `onlyFiles`, and `followSymbolicLinks` are `false` by default. | ||
| @returns The deleted paths. | ||
| console.log('Deleted files and directories:\n', deletedPaths.join('\n')); | ||
| ``` | ||
| */ | ||
| export function deleteAsync( | ||
| patterns: string | readonly string[], | ||
| options?: Options | ||
| ): Promise<string[]>; | ||
| @example | ||
| ``` | ||
| import del = require('del'); | ||
| /** | ||
| Synchronously delete files and directories using glob patterns. | ||
| (async () => { | ||
| const deletedPaths = await del(['temp/*.js', '!temp/unicorn.js']); | ||
| Note that glob patterns can only contain forward-slashes, not backward-slashes. Windows file paths can use backward-slashes as long as the path does not contain any glob-like characters, otherwise use `path.posix.join()` instead of `path.join()`. | ||
| console.log('Deleted files and directories:\n', deletedPaths.join('\n')); | ||
| })(); | ||
| ``` | ||
| */ | ||
| ( | ||
| patterns: string | readonly string[], | ||
| options?: del.Options | ||
| ): Promise<string[]>; | ||
| }; | ||
| export = del; | ||
| @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns). | ||
| - [Pattern examples with expected matches](https://github.com/sindresorhus/multimatch/blob/main/test/test.js) | ||
| - [Quick globbing pattern overview](https://github.com/sindresorhus/multimatch#globbing-patterns) | ||
| @param options - You can specify any of the [`globby` options](https://github.com/sindresorhus/globby#options) in addition to the `del` options. In contrast to the `globby` defaults, `expandDirectories`, `onlyFiles`, and `followSymbolicLinks` are `false` by default. | ||
| @returns The deleted paths. | ||
| */ | ||
| export function deleteSync( | ||
| patterns: string | readonly string[], | ||
| options?: Options | ||
| ): string[]; |
+23
-23
@@ -1,12 +0,12 @@ | ||
| 'use strict'; | ||
| const {promisify} = require('util'); | ||
| const path = require('path'); | ||
| const globby = require('globby'); | ||
| const isGlob = require('is-glob'); | ||
| const slash = require('slash'); | ||
| const gracefulFs = require('graceful-fs'); | ||
| const isPathCwd = require('is-path-cwd'); | ||
| const isPathInside = require('is-path-inside'); | ||
| const rimraf = require('rimraf'); | ||
| const pMap = require('p-map'); | ||
| 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 pMap from 'p-map'; | ||
@@ -28,3 +28,3 @@ const rimrafP = promisify(rimraf); | ||
| readdir: gracefulFs.readdir, | ||
| readdirSync: gracefulFs.readdirSync | ||
| readdirSync: gracefulFs.readdirSync, | ||
| }; | ||
@@ -56,3 +56,3 @@ | ||
| module.exports = async (patterns, {force, dryRun, cwd = process.cwd(), onProgress = () => {}, ...options} = {}) => { | ||
| export async function deleteAsync(patterns, {force, dryRun, cwd = process.cwd(), onProgress = () => {}, ...options} = {}) { | ||
| options = { | ||
@@ -63,3 +63,3 @@ expandDirectories: false, | ||
| cwd, | ||
| ...options | ||
| ...options, | ||
| }; | ||
@@ -69,4 +69,4 @@ | ||
| const files = (await globby(patterns, options)) | ||
| .sort((a, b) => b.localeCompare(a)); | ||
| const paths = await globby(patterns, options); | ||
| const files = paths.sort((a, b) => b.localeCompare(a)); | ||
@@ -77,3 +77,3 @@ if (files.length === 0) { | ||
| deletedCount: 0, | ||
| percent: 1 | ||
| percent: 1, | ||
| }); | ||
@@ -100,3 +100,3 @@ } | ||
| deletedCount, | ||
| percent: deletedCount / files.length | ||
| percent: deletedCount / files.length, | ||
| }); | ||
@@ -112,5 +112,5 @@ | ||
| return removedFiles; | ||
| }; | ||
| } | ||
| module.exports.sync = (patterns, {force, dryRun, cwd = process.cwd(), ...options} = {}) => { | ||
| export function deleteSync(patterns, {force, dryRun, cwd = process.cwd(), ...options} = {}) { | ||
| options = { | ||
@@ -121,3 +121,3 @@ expandDirectories: false, | ||
| cwd, | ||
| ...options | ||
| ...options, | ||
| }; | ||
@@ -127,3 +127,3 @@ | ||
| const files = globby.sync(patterns, options) | ||
| const files = globbySync(patterns, options) | ||
| .sort((a, b) => b.localeCompare(a)); | ||
@@ -148,2 +148,2 @@ | ||
| return removedFiles; | ||
| }; | ||
| } |
+20
-13
| { | ||
| "name": "del", | ||
| "version": "6.1.1", | ||
| "version": "7.0.0", | ||
| "description": "Delete files and directories", | ||
@@ -13,4 +13,7 @@ "license": "MIT", | ||
| }, | ||
| "type": "module", | ||
| "exports": "./index.js", | ||
| "types": "./index.d.ts", | ||
| "engines": { | ||
| "node": ">=10" | ||
| "node": ">=14.16" | ||
| }, | ||
@@ -50,19 +53,23 @@ "scripts": { | ||
| "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": "^2.4.0", | ||
| "ava": "^4.3.1", | ||
| "benchmark": "^2.1.4", | ||
| "make-dir": "^3.1.0", | ||
| "tempy": "^0.7.0", | ||
| "tsd": "^0.13.1", | ||
| "xo": "^0.33.1" | ||
| "tempy": "^3.0.0", | ||
| "tsd": "^0.22.0", | ||
| "xo": "^0.50.0" | ||
| }, | ||
| "ava": { | ||
| "serial": true, | ||
| "workerThreads": false | ||
| } | ||
| } |
+18
-22
@@ -9,5 +9,5 @@ # del | ||
| ```sh | ||
| npm install del | ||
| ``` | ||
| $ npm install del | ||
| ``` | ||
@@ -17,12 +17,10 @@ ## Usage | ||
| ```js | ||
| const del = require('del'); | ||
| import {deleteAsync} from 'del'; | ||
| (async () => { | ||
| const deletedFilePaths = await del(['temp/*.js', '!temp/unicorn.js']); | ||
| const deletedDirectoryPaths = await del(['temp', 'public']); | ||
| const deletedFilePaths = await deleteAsync(['temp/*.js', '!temp/unicorn.js']); | ||
| const deletedDirectoryPaths = await deleteAsync(['temp', 'public']); | ||
| console.log('Deleted files:\n', deletedFilePaths.join('\n')); | ||
| console.log('\n\n'); | ||
| console.log('Deleted directories:\n', deletedDirectoryPaths.join('\n')); | ||
| })(); | ||
| console.log('Deleted files:\n', deletedFilePaths.join('\n')); | ||
| console.log('\n\n'); | ||
| console.log('Deleted directories:\n', deletedDirectoryPaths.join('\n')); | ||
| ``` | ||
@@ -37,3 +35,3 @@ | ||
| ```js | ||
| del.sync(['public/assets/**', '!public/assets/goat.png']); | ||
| deleteSync(['public/assets/**', '!public/assets/goat.png']); | ||
| ``` | ||
@@ -44,3 +42,3 @@ | ||
| ```js | ||
| del.sync(['public/assets/**', '!public/assets', '!public/assets/goat.png']); | ||
| deleteSync(['public/assets/**', '!public/assets', '!public/assets/goat.png']); | ||
| ``` | ||
@@ -51,3 +49,3 @@ | ||
| ```js | ||
| del.sync(['public/*/']); | ||
| deleteSync(['public/*/']); | ||
| ``` | ||
@@ -61,7 +59,7 @@ | ||
| ### del(patterns, options?) | ||
| ### deleteAsync(patterns, options?) | ||
| Returns `Promise<string[]>` with the deleted paths. | ||
| ### del.sync(patterns, options?) | ||
| ### deleteSync(patterns, options?) | ||
@@ -100,9 +98,7 @@ Returns `string[]` with the deleted paths. | ||
| ```js | ||
| const del = require('del'); | ||
| import {deleteAsync} from 'del'; | ||
| (async () => { | ||
| const deletedPaths = await del(['temp/*.js'], {dryRun: true}); | ||
| const deletedPaths = await deleteAsync(['temp/*.js'], {dryRun: true}); | ||
| console.log('Files and directories that would be deleted:\n', deletedPaths.join('\n')); | ||
| })(); | ||
| console.log('Files and directories that would be deleted:\n', deletedPaths.join('\n')); | ||
| ``` | ||
@@ -125,5 +121,5 @@ | ||
| ```js | ||
| import del from 'del'; | ||
| import {deleteAsync} from 'del'; | ||
| await del(patterns, { | ||
| await deleteAsync(patterns, { | ||
| onProgress: progress => { | ||
@@ -130,0 +126,0 @@ // … |
12810
0.84%Yes
NaN190
-4.52%148
-2.63%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated
Updated
Updated
Updated
Updated