-
-
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.
Refactor TypeScript definition to CommonJS compatible export (#82)
- Loading branch information
1 parent
49e955b
commit 3f0d604
Showing
4 changed files
with
85 additions
and
62 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 |
---|---|---|
@@ -1,62 +1,83 @@ | ||
import {IOptions as GlobOptions} from 'glob'; | ||
|
||
interface Options extends Readonly<GlobOptions> { | ||
/** | ||
* Allow deleting the current working directory and outside. | ||
* | ||
* @default false | ||
*/ | ||
readonly force?: boolean; | ||
declare namespace del { | ||
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 = require('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; | ||
} | ||
} | ||
|
||
declare const del: { | ||
/** | ||
* 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; | ||
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. | ||
@example | ||
``` | ||
import del = require('del'); | ||
(async () => { | ||
const deletedPaths = await del(['tmp/*.js', '!tmp/unicorn.js']); | ||
console.log('Deleted files and folders:\n', deletedPaths.join('\n')); | ||
})(); | ||
``` | ||
*/ | ||
( | ||
patterns: string | ReadonlyArray<string>, | ||
options?: del.Options | ||
): Promise<string[]>; | ||
|
||
/** | ||
* Concurrency limit. Minimum: `1`. | ||
* | ||
* @default Infinity | ||
*/ | ||
readonly concurrency?: number; | ||
} | ||
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. | ||
*/ | ||
sync( | ||
patterns: string | ReadonlyArray<string>, | ||
options?: del.Options | ||
): string[]; | ||
|
||
// TODO: Remove this for the next major release | ||
default: typeof del; | ||
}; | ||
|
||
/** | ||
* 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[]; | ||
export = del; |
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
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