-
-
Notifications
You must be signed in to change notification settings - Fork 66
/
index.d.ts
113 lines (87 loc) · 3.45 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import {type Options as GlobbyOptions} from 'globby';
export type ProgressData = {
/**
Deleted files and directories count.
*/
readonly deletedCount: number;
/**
Total files and directories count.
*/
readonly totalCount: number;
/**
Completed percentage. A value between `0` and `1`.
*/
readonly percent: number;
/**
The absolute path of the deleted file or directory.
It will not be present if nothing was deleted.
*/
readonly path?: string;
};
export type Options = {
/**
Allow deleting the current working directory and outside.
@default false
*/
readonly force?: boolean;
/**
See what would be deleted.
@default false
@example
```
import {deleteAsync} from 'del';
const deletedPaths = await deleteAsync(['temp/*.js'], {dryRun: true});
console.log('Files and directories that would be deleted:\n', deletedPaths.join('\n'));
```
*/
readonly dryRun?: boolean;
/**
Concurrency limit. Minimum: `1`.
@default Infinity
*/
readonly concurrency?: number;
/**
Called after each file or directory is deleted.
@example
```
import {deleteAsync} from 'del';
await deleteAsync(patterns, {
onProgress: progress => {
// …
}});
```
*/
readonly onProgress?: (progress: ProgressData) => void;
} & GlobbyOptions;
/**
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()`.
@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.
@example
```
import {deleteAsync} from 'del';
const deletedPaths = await deleteAsync(['temp/*.js', '!temp/unicorn.js']);
console.log('Deleted files and directories:\n', deletedPaths.join('\n'));
```
*/
export function deleteAsync(
patterns: string | readonly string[],
options?: Options
): Promise<string[]>;
/**
Synchronously 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()`.
@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[];