Comparing version 10.1.0 to 11.0.0
@@ -1,9 +0,7 @@ | ||
import NestedError from 'nested-error-stacks'; | ||
export default class CpyError extends NestedError { | ||
constructor(message, nested) { | ||
super(message, nested); | ||
Object.assign(this, nested); | ||
export default class CpyError extends Error { | ||
constructor(message, {cause} = {}) { | ||
super(message, {cause}); | ||
Object.assign(this, cause); | ||
this.name = 'CpyError'; | ||
} | ||
} |
import {type Options as GlobOptions} from 'globby'; | ||
import {type Options as CpFileOptions} from 'cp-file'; | ||
import {type Options as CopyFileOptions} from 'copy-file'; | ||
@@ -106,3 +106,3 @@ export type Entry = { | ||
readonly filter?: (file: Entry) => boolean | Promise<boolean>; | ||
} & Readonly<GlobOptions> & CpFileOptions; // eslint-disable-line @typescript-eslint/no-redundant-type-constituents | ||
} & Readonly<GlobOptions> & CopyFileOptions; | ||
@@ -109,0 +109,0 @@ export type ProgressData = { |
27
index.js
@@ -6,4 +6,3 @@ import process from 'node:process'; | ||
import pMap from 'p-map'; | ||
import arrify from 'arrify'; | ||
import {copyFile} from 'cp-file'; | ||
import {copyFile} from 'copy-file'; | ||
import pFilter from 'p-filter'; | ||
@@ -15,4 +14,2 @@ import {isDynamicPattern} from 'globby'; | ||
const defaultConcurrency = (os.cpus().length || 1) * 2; // eslint-disable-line unicorn/explicit-length-check | ||
/** | ||
@@ -144,3 +141,3 @@ @type {import('./index').Options} | ||
destination, | ||
{concurrency = defaultConcurrency, ...options} = {}, | ||
{concurrency = os.availableParallelism(), ...options} = {}, | ||
) { | ||
@@ -173,4 +170,4 @@ /** | ||
*/ | ||
let patterns = expandPatternsWithBraceExpansion(arrify(source)) | ||
.map(string => string.replace(/\\/g, '/')); | ||
let patterns = expandPatternsWithBraceExpansion([source ?? []].flat()) | ||
.map(string => string.replaceAll('\\', '/')); | ||
const sources = patterns.filter(item => !item.startsWith('!')); | ||
@@ -194,12 +191,7 @@ const ignore = patterns.filter(item => item.startsWith('!')); | ||
} catch (error) { | ||
throw new CpyError( | ||
`Cannot glob \`${pattern.originalPath}\`: ${error.message}`, | ||
error, | ||
); | ||
throw new CpyError(`Cannot glob \`${pattern.originalPath}\`: ${error.message}`, {cause: error}); | ||
} | ||
if (matches.length === 0 && !isDynamicPattern(pattern.originalPath) && !isDynamicPattern(ignore)) { | ||
throw new CpyError( | ||
`Cannot copy \`${pattern.originalPath}\`: the file doesn't exist`, | ||
); | ||
throw new CpyError(`Cannot copy \`${pattern.originalPath}\`: the file doesn't exist`); | ||
} | ||
@@ -227,3 +219,3 @@ | ||
/** | ||
@param {import('cp-file').ProgressData} event | ||
@param {import('copy-file').ProgressData} event | ||
*/ | ||
@@ -278,6 +270,3 @@ const fileProgressHandler = event => { | ||
} catch (error) { | ||
throw new CpyError( | ||
`Cannot copy from \`${entry.relativePath}\` to \`${to}\`: ${error.message}`, | ||
error, | ||
); | ||
throw new CpyError(`Cannot copy from \`${entry.relativePath}\` to \`${to}\`: ${error.message}`, {cause: error}); | ||
} | ||
@@ -284,0 +273,0 @@ |
{ | ||
"name": "cpy", | ||
"version": "10.1.0", | ||
"version": "11.0.0", | ||
"description": "Copy files", | ||
@@ -14,5 +14,8 @@ "license": "MIT", | ||
"type": "module", | ||
"exports": "./index.js", | ||
"exports": { | ||
"types": "./index.d.ts", | ||
"default": "./index.js" | ||
}, | ||
"engines": { | ||
"node": ">=16" | ||
"node": ">=18" | ||
}, | ||
@@ -50,8 +53,6 @@ "scripts": { | ||
"dependencies": { | ||
"arrify": "^3.0.0", | ||
"cp-file": "^10.0.0", | ||
"globby": "^13.1.4", | ||
"copy-file": "^11.0.0", | ||
"globby": "^13.2.2", | ||
"junk": "^4.0.1", | ||
"micromatch": "^4.0.5", | ||
"nested-error-stacks": "^2.1.1", | ||
"p-filter": "^3.0.0", | ||
@@ -61,9 +62,14 @@ "p-map": "^6.0.0" | ||
"devDependencies": { | ||
"ava": "^5.2.0", | ||
"ava": "^5.3.1", | ||
"proxyquire": "^2.1.3", | ||
"rimraf": "^5.0.0", | ||
"tempy": "^3.0.0", | ||
"tsd": "^0.28.1", | ||
"xo": "^0.54.2" | ||
"rimraf": "^5.0.5", | ||
"tempy": "^3.1.0", | ||
"tsd": "^0.29.0", | ||
"xo": "^0.56.0" | ||
}, | ||
"xo": { | ||
"rules": { | ||
"unicorn/prefer-event-target": "off" | ||
} | ||
} | ||
} |
@@ -5,5 +5,7 @@ # cpy | ||
**IMPORTANT:** This package has a lot of problems and I unfortunately don't have time to fix them. I would recommend against using this package until these problems are resolved. Help welcome (see the issue tracker) 🙏 | ||
## Why | ||
- Fast by using streams. | ||
- Fast by [cloning](https://stackoverflow.com/questions/71629903/node-js-why-we-should-use-copyfile-ficlone-and-copyfile-ficlone-force-what-is) the files whenever possible. | ||
- Resilient by using [graceful-fs](https://github.com/isaacs/node-graceful-fs). | ||
@@ -229,4 +231,4 @@ - User-friendly by accepting [globs](https://github.com/sindresorhus/globby#globbing-patterns) and creating non-existent destination directories. | ||
- [cpy-cli](https://github.com/sindresorhus/cpy-cli) - CLI for this module | ||
- [cp-file](https://github.com/sindresorhus/cp-file) - Copy a single file | ||
- [copy-file](https://github.com/sindresorhus/copy-file) - Copy a single file | ||
- [move-file](https://github.com/sindresorhus/move-file) - Move a file | ||
- [make-dir](https://github.com/sindresorhus/make-dir) - Make a directory and its parents if needed |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18977
6
233
438
+ Addedcopy-file@^11.0.0
+ Addedcopy-file@11.0.0(transitive)
+ Addedp-event@6.0.1(transitive)
+ Addedp-timeout@6.1.3(transitive)
- Removedarrify@^3.0.0
- Removedcp-file@^10.0.0
- Removednested-error-stacks@^2.1.1
- Removedarrify@3.0.0(transitive)
- Removedcp-file@10.0.0(transitive)
- Removednested-error-stacks@2.1.1(transitive)
- Removedp-event@5.0.1(transitive)
- Removedp-timeout@5.1.0(transitive)
Updatedglobby@^13.2.2