-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
44 lines (36 loc) · 1.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
/**
Move or copy a file or whole directory from a source path to a destination path.
It takes a `source` and `destination` arguments that must be strings and paths to a file or directory.
It also takes an `options` argument that is an object with three boolean properties:
- `overwrite`: Whether to overwrite a file if it already exists in the destination. Default: `false`
- `copy`: If `true`, change the operation from moving to copying. Default: `false`
- `log`: Whether to print a message upon encountering an error. Default: `true`
Returns `undefined` if the operation is successful or a `CustomError` object.
The `CustomError` object returned upon errors has a `code` and a `message` properties:
- `code`: An integer number.
- `message`: A string containing the error message.
Here are the possible error codes and messages:
Code | Message
-----|-----------------------------------------
`1` | `'Invalid argument(s).'`
`2` | `'No such file or directory: ...'`
`3` | `'Destination already exists: ...'`
`4` | `'Destination is an existing file: ...'`
*/
declare function mvdir(source?: string, destination?: string, options?: Options): Promise<CustomError | undefined>;
interface Options {
overwrite?: boolean;
copy?: boolean;
log?: boolean;
}
interface CustomError {
code: ErrorCode;
message: string;
}
declare enum ErrorCode {
InvalidArgs = 1,
SrcNotExists = 2,
DestAlreadyExists = 3,
DestIsExistingFile = 4,
}
export default mvdir;