UNPKG

2.97 kBTypeScriptView Raw
1import {GlobbyOptions} from 'globby';
2
3declare namespace del {
4 interface Options extends GlobbyOptions {
5 /**
6 Allow deleting the current working directory and outside.
7
8 @default false
9 */
10 readonly force?: boolean;
11
12 /**
13 See what would be deleted.
14
15 @default false
16
17 @example
18 ```
19 import del = require('del');
20
21 (async () => {
22 const deletedPaths = await del(['temp/*.js'], {dryRun: true});
23
24 console.log('Files and directories that would be deleted:\n', deletedPaths.join('\n'));
25 })();
26 ```
27 */
28 readonly dryRun?: boolean;
29
30 /**
31 Concurrency limit. Minimum: `1`.
32
33 @default Infinity
34 */
35 readonly concurrency?: number;
36 }
37}
38
39declare const del: {
40 /**
41 Delete files and directories using glob patterns.
42
43 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()`.
44
45 @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
46 - [Pattern examples with expected matches](https://github.com/sindresorhus/multimatch/blob/master/test/test.js)
47 - [Quick globbing pattern overview](https://github.com/sindresorhus/multimatch#globbing-patterns)
48 @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.
49 @returns The deleted paths.
50
51 @example
52 ```
53 import del = require('del');
54
55 (async () => {
56 const deletedPaths = await del(['temp/*.js', '!temp/unicorn.js']);
57
58 console.log('Deleted files and directories:\n', deletedPaths.join('\n'));
59 })();
60 ```
61 */
62 (
63 patterns: string | readonly string[],
64 options?: del.Options
65 ): Promise<string[]>;
66
67 /**
68 Synchronously delete files and directories using glob patterns.
69
70 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()`.
71
72 @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
73 - [Pattern examples with expected matches](https://github.com/sindresorhus/multimatch/blob/master/test/test.js)
74 - [Quick globbing pattern overview](https://github.com/sindresorhus/multimatch#globbing-patterns)
75 @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.
76 @returns The deleted paths.
77 */
78 sync(
79 patterns: string | readonly string[],
80 options?: del.Options
81 ): string[];
82};
83
84export = del;