|
1 | 1 | import {GlobbyOptions} from 'globby'; |
2 | 2 |
|
3 | | -declare namespace del { |
4 | | - interface ProgressData { |
5 | | - /** |
6 | | - Deleted files and directories count. |
7 | | - */ |
8 | | - deletedCount: number; |
9 | | - |
10 | | - /** |
11 | | - Total files and directories count. |
12 | | - */ |
13 | | - totalCount: number; |
14 | | - |
15 | | - /** |
16 | | - Completed percentage. A value between `0` and `1`. |
17 | | - */ |
18 | | - percent: number; |
19 | | - } |
20 | | - |
21 | | - interface Options extends GlobbyOptions { |
22 | | - /** |
23 | | - Allow deleting the current working directory and outside. |
24 | | -
|
25 | | - @default false |
26 | | - */ |
27 | | - readonly force?: boolean; |
28 | | - |
29 | | - /** |
30 | | - See what would be deleted. |
31 | | -
|
32 | | - @default false |
33 | | -
|
34 | | - @example |
35 | | - ``` |
36 | | - import del = require('del'); |
37 | | -
|
38 | | - (async () => { |
39 | | - const deletedPaths = await del(['temp/*.js'], {dryRun: true}); |
40 | | -
|
41 | | - console.log('Files and directories that would be deleted:\n', deletedPaths.join('\n')); |
42 | | - })(); |
43 | | - ``` |
44 | | - */ |
45 | | - readonly dryRun?: boolean; |
46 | | - |
47 | | - /** |
48 | | - Concurrency limit. Minimum: `1`. |
49 | | -
|
50 | | - @default Infinity |
51 | | - */ |
52 | | - readonly concurrency?: number; |
53 | | - |
54 | | - /** |
55 | | - Called after each file or directory is deleted. |
56 | | -
|
57 | | - @example |
58 | | - ``` |
59 | | - import del from 'del'; |
60 | | -
|
61 | | - await del(patterns, { |
62 | | - onProgress: progress => { |
63 | | - // … |
64 | | - }}); |
65 | | - ``` |
66 | | - */ |
67 | | - readonly onProgress?: (progress: ProgressData) => void; |
68 | | - } |
| 3 | +export interface ProgressData { |
| 4 | + /** |
| 5 | + Deleted files and directories count. |
| 6 | + */ |
| 7 | + deletedCount: number; |
| 8 | + |
| 9 | + /** |
| 10 | + Total files and directories count. |
| 11 | + */ |
| 12 | + totalCount: number; |
| 13 | + |
| 14 | + /** |
| 15 | + Completed percentage. A value between `0` and `1`. |
| 16 | + */ |
| 17 | + percent: number; |
69 | 18 | } |
70 | 19 |
|
71 | | -declare const del: { |
| 20 | +export interface Options extends GlobbyOptions { |
72 | 21 | /** |
73 | | - Synchronously delete files and directories using glob patterns. |
| 22 | + Allow deleting the current working directory and outside. |
74 | 23 |
|
75 | | - 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()`. |
| 24 | + @default false |
| 25 | + */ |
| 26 | + readonly force?: boolean; |
| 27 | + |
| 28 | + /** |
| 29 | + See what would be deleted. |
76 | 30 |
|
77 | | - @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns). |
78 | | - - [Pattern examples with expected matches](https://github.com/sindresorhus/multimatch/blob/main/test/test.js) |
79 | | - - [Quick globbing pattern overview](https://github.com/sindresorhus/multimatch#globbing-patterns) |
80 | | - @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. |
81 | | - @returns The deleted paths. |
| 31 | + @default false |
| 32 | +
|
| 33 | + @example |
| 34 | + ``` |
| 35 | + import {deleteAsync} from 'del'; |
| 36 | +
|
| 37 | + const deletedPaths = await deleteAsync(['temp/*.js'], {dryRun: true}); |
| 38 | +
|
| 39 | + console.log('Files and directories that would be deleted:\n', deletedPaths.join('\n')); |
| 40 | + ``` |
82 | 41 | */ |
83 | | - sync: ( |
84 | | - patterns: string | readonly string[], |
85 | | - options?: del.Options |
86 | | - ) => string[]; |
| 42 | + readonly dryRun?: boolean; |
87 | 43 |
|
88 | 44 | /** |
89 | | - Delete files and directories using glob patterns. |
| 45 | + Concurrency limit. Minimum: `1`. |
90 | 46 |
|
91 | | - 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()`. |
| 47 | + @default Infinity |
| 48 | + */ |
| 49 | + readonly concurrency?: number; |
92 | 50 |
|
93 | | - @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns). |
94 | | - - [Pattern examples with expected matches](https://github.com/sindresorhus/multimatch/blob/main/test/test.js) |
95 | | - - [Quick globbing pattern overview](https://github.com/sindresorhus/multimatch#globbing-patterns) |
96 | | - @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. |
97 | | - @returns The deleted paths. |
| 51 | + /** |
| 52 | + Called after each file or directory is deleted. |
98 | 53 |
|
99 | 54 | @example |
100 | 55 | ``` |
101 | | - import del = require('del'); |
| 56 | + import {deleteAsync} from 'del'; |
102 | 57 |
|
103 | | - (async () => { |
104 | | - const deletedPaths = await del(['temp/*.js', '!temp/unicorn.js']); |
105 | | -
|
106 | | - console.log('Deleted files and directories:\n', deletedPaths.join('\n')); |
107 | | - })(); |
| 58 | + await deleteAsync(patterns, { |
| 59 | + onProgress: progress => { |
| 60 | + // … |
| 61 | + }}); |
108 | 62 | ``` |
109 | 63 | */ |
110 | | - ( |
111 | | - patterns: string | readonly string[], |
112 | | - options?: del.Options |
113 | | - ): Promise<string[]>; |
114 | | -}; |
| 64 | + readonly onProgress?: (progress: ProgressData) => void; |
| 65 | +} |
115 | 66 |
|
116 | | -export = del; |
| 67 | +/** |
| 68 | +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/main/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 | +@example |
| 79 | +``` |
| 80 | +import {deleteAsync} from 'del'; |
| 81 | +
|
| 82 | +const deletedPaths = await deleteAsync(['temp/*.js', '!temp/unicorn.js']); |
| 83 | +
|
| 84 | +console.log('Deleted files and directories:\n', deletedPaths.join('\n')); |
| 85 | +``` |
| 86 | +*/ |
| 87 | +export function deleteAsync( |
| 88 | + patterns: string | readonly string[], |
| 89 | + options?: Options |
| 90 | +): Promise<string[]>; |
| 91 | + |
| 92 | +/** |
| 93 | +Synchronously delete files and directories using glob patterns. |
| 94 | +
|
| 95 | +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()`. |
| 96 | +
|
| 97 | +@param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns). |
| 98 | +- [Pattern examples with expected matches](https://github.com/sindresorhus/multimatch/blob/main/test/test.js) |
| 99 | +- [Quick globbing pattern overview](https://github.com/sindresorhus/multimatch#globbing-patterns) |
| 100 | +@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. |
| 101 | +@returns The deleted paths. |
| 102 | +*/ |
| 103 | +export function deleteSync( |
| 104 | + patterns: string | readonly string[], |
| 105 | + options?: Options |
| 106 | +): string[]; |
0 commit comments