/
index.d.ts
97 lines (78 loc) · 1.78 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
import {GlobbyOptions} from 'globby';
import {Options as CpFileOptions} from 'cp-file';
declare namespace cpy {
interface Options extends Readonly<GlobbyOptions>, CpFileOptions {
/**
Working directory to find source files.
@default process.cwd()
*/
readonly cwd?: string;
/**
Preserve path structure.
@default false
*/
readonly parents?: boolean;
/**
Filename or function returning a filename used to rename every file in `source`.
@example
```
import cpy = require('cpy');
(async () => {
await cpy('foo.js', 'destination', {
rename: basename => `prefix-${basename}`
});
})();
```
*/
readonly rename?: string | ((basename: string) => string);
/**
Number of files being copied concurrently.
@default (os.cpus().length || 1) * 2
*/
readonly concurrency?: number;
}
interface ProgressData {
/**
Copied file count.
*/
completedFiles: number;
/**
Overall file count.
*/
totalFiles: number;
/**
Completed size in bytes.
*/
completedSize: number;
/**
Completed percentage. A value between `0` and `1`.
*/
percent: number;
}
interface ProgressEmitter {
on(
event: 'progress',
handler: (progress: ProgressData) => void
): Promise<string[]>;
}
}
/**
Copy files.
@param source - Files to copy.
@param destination - Destination directory.
@param options - In addition to the options defined here, options are passed to [globby](https://github.com/sindresorhus/globby#options).
@example
```
import cpy = require('cpy');
(async () => {
await cpy(['source/*.png', '!source/goat.png'], 'destination');
console.log('Files copied!');
})();
```
*/
declare function cpy(
source: string | ReadonlyArray<string>,
destination: string,
options?: cpy.Options
): Promise<string[]> & cpy.ProgressEmitter;
export = cpy;