-
Notifications
You must be signed in to change notification settings - Fork 574
/
_fs_rmdir.ts
35 lines (30 loc) · 955 Bytes
/
_fs_rmdir.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
type rmdirOptions = {
maxRetries?: number;
recursive?: boolean;
retryDelay?: number;
};
type rmdirCallback = (err?: Error) => void;
export function rmdir(path: string | URL, callback: rmdirCallback): void;
export function rmdir(
path: string | URL,
options: rmdirOptions,
callback: rmdirCallback,
): void;
export function rmdir(
path: string | URL,
optionsOrCallback: rmdirOptions | rmdirCallback,
maybeCallback?: rmdirCallback,
) {
const callback = typeof optionsOrCallback === "function"
? optionsOrCallback
: maybeCallback;
const options = typeof optionsOrCallback === "object"
? optionsOrCallback
: undefined;
if (!callback) throw new Error("No callback function supplied");
Deno.remove(path, { recursive: options?.recursive })
.then((_) => callback(), callback);
}
export function rmdirSync(path: string | URL, options?: rmdirOptions) {
Deno.removeSync(path, { recursive: options?.recursive });
}