Skip to content

Commit 61b9de2

Browse files
committed
Require Node.js 20
Fixes #117 #105
1 parent 3cbdad1 commit 61b9de2

File tree

6 files changed

+49
-69
lines changed

6 files changed

+49
-69
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
node-version:
13+
- 24
14+
- 22
1315
- 20
14-
- 18
1516
os:
1617
- ubuntu-latest
1718
- macos-latest

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ const renameFile = (source, rename) => {
164164
export default function cpy(
165165
source,
166166
destination,
167-
{concurrency = os.availableParallelism(), ...options} = {}, // eslint-disable-line n/no-unsupported-features/node-builtins
167+
{concurrency = os.availableParallelism(), ...options} = {},
168168
) {
169169
const copyStatus = new Map();
170170

index.test-d.ts

Lines changed: 28 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,35 @@
11
import {expectType} from 'tsd';
22
import cpy, {type ProgressEmitter, type ProgressData, type Entry} from './index.js';
33

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}));
1111

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);
2615

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}));
3125

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);
4428

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+
}));

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"sideEffects": false,
1919
"engines": {
20-
"node": ">=18"
20+
"node": ">=20"
2121
},
2222
"scripts": {
2323
"test": "xo && ava && tsd"
@@ -50,20 +50,20 @@
5050
"directories"
5151
],
5252
"dependencies": {
53-
"copy-file": "^11.0.0",
54-
"globby": "^14.0.2",
53+
"copy-file": "^11.1.0",
54+
"globby": "^14.1.0",
5555
"junk": "^4.0.1",
56-
"micromatch": "^4.0.7",
56+
"micromatch": "^4.0.8",
5757
"p-filter": "^4.1.0",
58-
"p-map": "^7.0.2"
58+
"p-map": "^7.0.3"
5959
},
6060
"devDependencies": {
61-
"ava": "^6.1.3",
61+
"ava": "^6.4.1",
6262
"proxyquire": "^2.1.3",
63-
"rimraf": "^5.0.5",
63+
"rimraf": "^6.0.1",
6464
"tempy": "^3.1.0",
65-
"tsd": "^0.31.1",
66-
"xo": "^0.59.2"
65+
"tsd": "^0.33.0",
66+
"xo": "^1.2.1"
6767
},
6868
"xo": {
6969
"rules": {

readme.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ Default: `process.cwd()`
7878

7979
Working directory to find source files.
8080

81+
> [!NOTE]
82+
> Globs and explicit paths preserve paths differently.
83+
> Globs keep paths **relative to the glob’s parent** (`source/*.md``distribution/readme.md`).
84+
> Explicit paths keep paths **relative to `cwd`** (`source/file.js``distribution/source/file.js`).
85+
> Use a single glob or set `cwd` so all patterns share the same base.
86+
8187
##### overwrite
8288

8389
Type: `boolean`\

test.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,8 @@ test('copy array of files', async t => {
5353
});
5454

5555
test('throws on invalid concurrency value', async t => {
56-
await t.throwsAsync(
57-
cpy(['license', 'package.json'], t.context.tmp, {concurrency: -2}),
58-
);
59-
await t.throwsAsync(
60-
cpy(['license', 'package.json'], t.context.tmp, {concurrency: 'foo'}),
61-
);
56+
await t.throwsAsync(cpy(['license', 'package.json'], t.context.tmp, {concurrency: -2}));
57+
await t.throwsAsync(cpy(['license', 'package.json'], t.context.tmp, {concurrency: 'foo'}));
6258
});
6359

6460
test('copy array of files with filter', async t => {
@@ -315,9 +311,7 @@ test('flatten directory tree', async t => {
315311
read(t.context.tmp, 'source/bar.js'),
316312
read(t.context.tmp, 'destination/subdir/bar.js'),
317313
);
318-
t.falsy(
319-
fs.existsSync(path.join(t.context.tmp, 'destination/subdir/baz.ts')),
320-
);
314+
t.falsy(fs.existsSync(path.join(t.context.tmp, 'destination/subdir/baz.ts')));
321315
});
322316

323317
test('flatten single file', async t => {

0 commit comments

Comments
 (0)