|
1 | 1 | import {expectType} from 'tsd'; |
2 | 2 | import cpy, {type ProgressEmitter, type ProgressData, type Entry} from './index.js'; |
3 | 3 |
|
4 | | -expectType<Promise<string[]> & ProgressEmitter>( |
5 | | - cpy(['source/*.png', '!source/goat.png'], 'destination'), |
6 | | -); |
7 | | -expectType<Promise<string[]> & ProgressEmitter>( |
8 | | - cpy('foo.js', 'destination', {rename: 'foobar'}), |
9 | | -); |
10 | | -expectType<Promise<string[]> & ProgressEmitter>( |
| 4 | +expectType<Promise<string[]> & ProgressEmitter>(cpy(['source/*.png', '!source/goat.png'], 'destination')); |
| 5 | +expectType<Promise<string[]> & ProgressEmitter>(cpy('foo.js', 'destination', {rename: 'foobar'})); |
| 6 | +expectType<Promise<string[]> & ProgressEmitter>(cpy('foo.js', 'destination', {rename: basename => `prefix-${basename}`})); |
| 7 | +expectType<Promise<string[]> & ProgressEmitter>(cpy('foo.js', 'destination', {cwd: '/'})); |
| 8 | +expectType<Promise<string[]> & ProgressEmitter>(cpy('foo.js', 'destination', {flat: true})); |
| 9 | +expectType<Promise<string[]> & ProgressEmitter>(cpy('foo.js', 'destination', {overwrite: false})); |
| 10 | +expectType<Promise<string[]> & ProgressEmitter>(cpy('foo.js', 'destination', {concurrency: 2})); |
11 | 11 |
|
12 | | - cpy('foo.js', 'destination', {rename: basename => `prefix-${basename}`}), |
13 | | -); |
14 | | -expectType<Promise<string[]> & ProgressEmitter>( |
15 | | - cpy('foo.js', 'destination', {cwd: '/'}), |
16 | | -); |
17 | | -expectType<Promise<string[]> & ProgressEmitter>( |
18 | | - cpy('foo.js', 'destination', {flat: true}), |
19 | | -); |
20 | | -expectType<Promise<string[]> & ProgressEmitter>( |
21 | | - cpy('foo.js', 'destination', {overwrite: false}), |
22 | | -); |
23 | | -expectType<Promise<string[]> & ProgressEmitter>( |
24 | | - cpy('foo.js', 'destination', {concurrency: 2}), |
25 | | -); |
| 12 | +expectType<Promise<string[]> & ProgressEmitter>(cpy('foo.js', 'destination', { |
| 13 | + filter(file) { |
| 14 | + expectType<Entry>(file); |
26 | 15 |
|
27 | | -expectType<Promise<string[]> & ProgressEmitter>( |
28 | | - cpy('foo.js', 'destination', { |
29 | | - filter(file) { |
30 | | - expectType<Entry>(file); |
| 16 | + expectType<string>(file.path); |
| 17 | + expectType<string>(file.relativePath); |
| 18 | + expectType<string>(file.name); |
| 19 | + expectType<string>(file.nameWithoutExtension); |
| 20 | + expectType<string>(file.extension); |
| 21 | + return true; |
| 22 | + }, |
| 23 | +})); |
| 24 | +expectType<Promise<string[]> & ProgressEmitter>(cpy('foo.js', 'destination', {filter: async (_file: Entry) => true})); |
31 | 25 |
|
32 | | - expectType<string>(file.path); |
33 | | - expectType<string>(file.relativePath); |
34 | | - expectType<string>(file.name); |
35 | | - expectType<string>(file.nameWithoutExtension); |
36 | | - expectType<string>(file.extension); |
37 | | - return true; |
38 | | - }, |
39 | | - }), |
40 | | -); |
41 | | -expectType<Promise<string[]> & ProgressEmitter>( |
42 | | - cpy('foo.js', 'destination', {filter: async (_file: Entry) => true}), |
43 | | -); |
| 26 | +expectType<Promise<string[]>>(cpy('foo.js', 'destination').on('progress', progress => { |
| 27 | + expectType<ProgressData>(progress); |
44 | 28 |
|
45 | | -expectType<Promise<string[]>>( |
46 | | - cpy('foo.js', 'destination').on('progress', progress => { |
47 | | - expectType<ProgressData>(progress); |
48 | | - |
49 | | - expectType<number>(progress.completedFiles); |
50 | | - expectType<number>(progress.totalFiles); |
51 | | - expectType<number>(progress.completedSize); |
52 | | - expectType<number>(progress.percent); |
53 | | - expectType<string>(progress.sourcePath); |
54 | | - expectType<string>(progress.destinationPath); |
55 | | - }), |
56 | | -); |
| 29 | + expectType<number>(progress.completedFiles); |
| 30 | + expectType<number>(progress.totalFiles); |
| 31 | + expectType<number>(progress.completedSize); |
| 32 | + expectType<number>(progress.percent); |
| 33 | + expectType<string>(progress.sourcePath); |
| 34 | + expectType<string>(progress.destinationPath); |
| 35 | +})); |
0 commit comments