Skip to content

Commit 1e39ee8

Browse files
committed
Meta tweaks
1 parent 0934ab1 commit 1e39ee8

File tree

5 files changed

+26
-29
lines changed

5 files changed

+26
-29
lines changed

index.js

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import process from 'node:process';
12
import EventEmitter from 'node:events';
23
import path from 'node:path';
34
import os from 'node:os';
@@ -62,17 +63,12 @@ Expand patterns like `'node_modules/{globby,micromatch}'` into `['node_modules/g
6263
@param {string[]} patterns
6364
@returns {string[]}
6465
*/
65-
const expandPatternsWithBraceExpansion = patterns => {
66-
let collection = [];
67-
for (const pattern of patterns) {
68-
collection = [...collection, ...micromatch.braces(pattern, {
69-
expand: true,
70-
nodupes: true,
71-
})];
72-
}
73-
74-
return collection;
75-
};
66+
const expandPatternsWithBraceExpansion = patterns => patterns.flatMap(pattern => (
67+
micromatch.braces(pattern, {
68+
expand: true,
69+
nodupes: true,
70+
})
71+
));
7672

7773
/**
7874
@param {object} props
@@ -119,14 +115,14 @@ const preprocessDestinationPath = ({entry, destination, options}) => {
119115
*/
120116
const renameFile = (source, rename) => {
121117
const filename = path.basename(source, path.extname(source));
122-
const ext = path.extname(source);
123-
const dir = path.dirname(source);
118+
const fileExtension = path.extname(source);
119+
const directory = path.dirname(source);
124120
if (typeof rename === 'string') {
125-
return path.join(dir, rename);
121+
return path.join(directory, rename);
126122
}
127123

128124
if (typeof rename === 'function') {
129-
return path.join(dir, `${rename(filename)}${ext}`);
125+
return path.join(directory, `${rename(filename)}${fileExtension}`);
130126
}
131127

132128
return source;

index.test-d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ expectType<Promise<string[]> & ProgressEmitter>(
2525

2626
expectType<Promise<string[]> & ProgressEmitter>(
2727
cpy('foo.js', 'destination', {
28-
filter: file => {
28+
filter(file) {
2929
expectType<Entry>(file);
3030

3131
expectType<string>(file.path);

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"type": "module",
1414
"exports": "./index.js",
1515
"engines": {
16-
"node": ">=12.20"
16+
"node": "^12.20.0 || ^14.17.0 || >=16.0.0"
1717
},
1818
"scripts": {
1919
"test": "xo && ava && tsd"
@@ -48,20 +48,20 @@
4848
"dependencies": {
4949
"arrify": "^3.0.0",
5050
"cp-file": "^9.1.0",
51-
"globby": "^12.0.2",
51+
"globby": "^13.1.1",
5252
"junk": "^4.0.0",
53-
"micromatch": "^4.0.4",
53+
"micromatch": "^4.0.4",
5454
"nested-error-stacks": "^2.1.0",
5555
"p-filter": "^3.0.0",
5656
"p-map": "^5.3.0"
5757
},
5858
"devDependencies": {
59-
"ava": "^3.15.0",
59+
"ava": "^4.0.1",
6060
"proxyquire": "^2.1.3",
6161
"rimraf": "^3.0.2",
6262
"tempy": "^2.0.0",
63-
"tsd": "^0.18.0",
64-
"typescript": "^4.4.4",
65-
"xo": "^0.42.0"
63+
"tsd": "^0.19.1",
64+
"typescript": "^4.5.5",
65+
"xo": "^0.48.0"
6666
}
6767
}

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
## Install
1414

15-
```
16-
$ npm install cpy
15+
```sh
16+
npm install cpy
1717
```
1818

1919
## Usage

test.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import process from 'node:process';
12
import path from 'node:path';
23
import fs from 'node:fs';
34
import crypto from 'node:crypto';
@@ -8,7 +9,7 @@ import proxyquire from 'proxyquire';
89
import CpyError from './cpy-error.js';
910
import cpy from './index.js';
1011

11-
const read = (...args) => fs.readFileSync(path.join(...args), 'utf8');
12+
const read = (...arguments_) => fs.readFileSync(path.join(...arguments_), 'utf8');
1213

1314
const cpyMockedError = module => proxyquire('.', {
1415
[module]() {
@@ -62,7 +63,7 @@ test('throws on invalid concurrency value', async t => {
6263

6364
test('copy array of files with filter', async t => {
6465
await cpy(['license', 'package.json'], t.context.tmp, {
65-
filter: file => {
66+
filter(file) {
6667
if (file.path.endsWith('license')) {
6768
t.is(file.path, path.join(process.cwd(), 'license'));
6869
t.is(file.name, 'license');
@@ -85,7 +86,7 @@ test('copy array of files with filter', async t => {
8586

8687
test('copy array of files with async filter', async t => {
8788
await cpy(['license', 'package.json'], t.context.tmp, {
88-
filter: async file => {
89+
async filter(file) {
8990
if (file.path.endsWith(`${path.sep}license`)) {
9091
t.is(file.path, path.join(process.cwd(), 'license'));
9192
t.is(file.name, 'license');
@@ -411,7 +412,7 @@ test('reports correct completedSize', async t => {
411412
test('returns the event emitter on early rejection', t => {
412413
const rejectedPromise = cpy(null, null);
413414
t.is(typeof rejectedPromise.on, 'function');
414-
rejectedPromise.catch(() => {}); // eslint-disable-line promise/prefer-await-to-then
415+
rejectedPromise.catch(() => {});
415416
});
416417

417418
test('returns destination path', async t => {

0 commit comments

Comments
 (0)