-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e73cc8a
commit 34c771e
Showing
4 changed files
with
95 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import {IOptions as GlobOptions} from 'glob'; | ||
|
||
interface Options extends Readonly<GlobOptions> { | ||
/** | ||
* Allow deleting the current working directory and outside. | ||
* | ||
* @default false | ||
*/ | ||
readonly force?: boolean; | ||
|
||
/** | ||
* See what would be deleted. | ||
* | ||
* @default false | ||
* | ||
* @example | ||
* | ||
* import del from 'del'; | ||
* | ||
* (async () => { | ||
* const deletedPaths = await del(['tmp/*.js'], {dryRun: true}); | ||
* | ||
* console.log('Files and folders that would be deleted:\n', deletedPaths.join('\n')); | ||
* })(); | ||
*/ | ||
readonly dryRun?: boolean; | ||
|
||
/** | ||
* Concurrency limit. Minimum: `1`. | ||
* | ||
* @default Infinity | ||
*/ | ||
readonly concurrency?: number; | ||
} | ||
|
||
/** | ||
* Delete files and folders using glob patterns. | ||
* | ||
* @param patterns - See supported minimatch [patterns](https://github.com/isaacs/minimatch#usage). | ||
* - [Pattern examples with expected matches](https://github.com/sindresorhus/multimatch/blob/master/test/test.js) | ||
* - [Quick globbing pattern overview](https://github.com/sindresorhus/multimatch#globbing-patterns) | ||
* @param options - See the [`glob` options](https://github.com/isaacs/node-glob#options). | ||
* @returns A promise for an array of deleted paths. | ||
*/ | ||
export default function del( | ||
patterns: string | ReadonlyArray<string>, | ||
options?: Options | ||
): Promise<string[]>; | ||
|
||
/** | ||
* Synchronously delete files and folders using glob patterns. | ||
* | ||
* @param patterns - See supported minimatch [patterns](https://github.com/isaacs/minimatch#usage). | ||
* - [Pattern examples with expected matches](https://github.com/sindresorhus/multimatch/blob/master/test/test.js) | ||
* - [Quick globbing pattern overview](https://github.com/sindresorhus/multimatch#globbing-patterns) | ||
* @param options - See the [`glob` options](https://github.com/isaacs/node-glob#options). | ||
* @returns An array of deleted paths. | ||
*/ | ||
export function sync( | ||
patterns: string | ReadonlyArray<string>, | ||
options?: Options | ||
): string[]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {expectType} from 'tsd-check'; | ||
import del, {sync as delSync} from '.'; | ||
|
||
let paths = ['tmp/*.js', '!tmp/unicorn.js']; | ||
|
||
// Del | ||
expectType<Promise<string[]>>(del('tmp/*.js')); | ||
expectType<Promise<string[]>>(del(paths)); | ||
|
||
expectType<Promise<string[]>>(del(paths, {force: true})); | ||
expectType<Promise<string[]>>(del(paths, {dryRun: true})); | ||
expectType<Promise<string[]>>(del(paths, {concurrency: 20})); | ||
expectType<Promise<string[]>>(del(paths, {cwd: ''})); | ||
|
||
// Del (sync) | ||
expectType<string[]>(delSync('tmp/*.js')); | ||
expectType<string[]>(delSync(paths)); | ||
|
||
expectType<string[]>(delSync(paths, {force: true})); | ||
expectType<string[]>(delSync(paths, {dryRun: true})); | ||
expectType<string[]>(delSync(paths, {concurrency: 20})); | ||
expectType<string[]>(delSync(paths, {cwd: ''})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters