-
-
Notifications
You must be signed in to change notification settings - Fork 63
/
index.test-d.ts
56 lines (50 loc) · 1.7 KB
/
index.test-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
import {expectType} from 'tsd';
import cpy, {type ProgressEmitter, type ProgressData, type Entry} from './index.js';
expectType<Promise<string[]> & ProgressEmitter>(
cpy(['source/*.png', '!source/goat.png'], 'destination'),
);
expectType<Promise<string[]> & ProgressEmitter>(
cpy('foo.js', 'destination', {rename: 'foobar'}),
);
expectType<Promise<string[]> & ProgressEmitter>(
cpy('foo.js', 'destination', {rename: basename => `prefix-${basename}`}),
);
expectType<Promise<string[]> & ProgressEmitter>(
cpy('foo.js', 'destination', {cwd: '/'}),
);
expectType<Promise<string[]> & ProgressEmitter>(
cpy('foo.js', 'destination', {flat: true}),
);
expectType<Promise<string[]> & ProgressEmitter>(
cpy('foo.js', 'destination', {overwrite: false}),
);
expectType<Promise<string[]> & ProgressEmitter>(
cpy('foo.js', 'destination', {concurrency: 2}),
);
expectType<Promise<string[]> & ProgressEmitter>(
cpy('foo.js', 'destination', {
filter(file) {
expectType<Entry>(file);
expectType<string>(file.path);
expectType<string>(file.relativePath);
expectType<string>(file.name);
expectType<string>(file.nameWithoutExtension);
expectType<string>(file.extension);
return true;
},
}),
);
expectType<Promise<string[]> & ProgressEmitter>(
cpy('foo.js', 'destination', {filter: async (_file: Entry) => true}),
);
expectType<Promise<string[]>>(
cpy('foo.js', 'destination').on('progress', progress => {
expectType<ProgressData>(progress);
expectType<number>(progress.completedFiles);
expectType<number>(progress.totalFiles);
expectType<number>(progress.completedSize);
expectType<number>(progress.percent);
expectType<string>(progress.sourcePath);
expectType<string>(progress.destinationPath);
}),
);