Comparing version 6.0.0 to 7.0.0
33
index.js
@@ -9,19 +9,19 @@ 'use strict'; | ||
const preprocessSrcPath = (srcPath, opts) => opts.cwd ? path.resolve(opts.cwd, srcPath) : srcPath; | ||
const preprocessSrcPath = (srcPath, options) => options.cwd ? path.resolve(options.cwd, srcPath) : srcPath; | ||
const preprocessDestPath = (srcPath, dest, opts) => { | ||
const preprocessDestPath = (srcPath, dest, options) => { | ||
let basename = path.basename(srcPath); | ||
const dirname = path.dirname(srcPath); | ||
if (typeof opts.rename === 'string') { | ||
basename = opts.rename; | ||
} else if (typeof opts.rename === 'function') { | ||
basename = opts.rename(basename); | ||
if (typeof options.rename === 'string') { | ||
basename = options.rename; | ||
} else if (typeof options.rename === 'function') { | ||
basename = options.rename(basename); | ||
} | ||
if (opts.cwd) { | ||
dest = path.resolve(opts.cwd, dest); | ||
if (options.cwd) { | ||
dest = path.resolve(options.cwd, dest); | ||
} | ||
if (opts.parents) { | ||
if (options.parents) { | ||
return path.join(dest, dirname, basename); | ||
@@ -33,5 +33,4 @@ } | ||
module.exports = (src, dest, opts) => { | ||
module.exports = (src, dest, options = {}) => { | ||
src = arrify(src); | ||
opts = opts || {}; | ||
@@ -47,3 +46,3 @@ if (src.length === 0 || !dest) { | ||
const promise = globby(src, opts) | ||
const promise = globby(src, options) | ||
.catch(err => { | ||
@@ -63,6 +62,6 @@ throw new CpyError(`Cannot glob \`${src}\`: ${err.message}`, err); | ||
return Promise.all(files.map(srcPath => { | ||
const from = preprocessSrcPath(srcPath, opts); | ||
const to = preprocessDestPath(srcPath, dest, opts); | ||
const from = preprocessSrcPath(srcPath, options); | ||
const to = preprocessDestPath(srcPath, dest, options); | ||
return cpFile(from, to, opts) | ||
return cpFile(from, to, options) | ||
.on('progress', event => { | ||
@@ -95,4 +94,4 @@ const fileStatus = copyStatus.get(event.src) || {written: 0, percent: 0}; | ||
promise.on = function () { | ||
progressEmitter.on.apply(progressEmitter, arguments); | ||
promise.on = (...args) => { | ||
progressEmitter.on(...args); | ||
return promise; | ||
@@ -99,0 +98,0 @@ }; |
114
package.json
{ | ||
"name": "cpy", | ||
"version": "6.0.0", | ||
"description": "Copy files", | ||
"license": "MIT", | ||
"repository": "sindresorhus/cpy", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"maintainers": [ | ||
{ | ||
"name": "Michael Mayer", | ||
"email": "michael@schnittstabil.de", | ||
"url": "schnittstabil.de" | ||
} | ||
], | ||
"engines": { | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"cpy-error.js", | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"copy", | ||
"cp", | ||
"cpy", | ||
"file", | ||
"files", | ||
"clone", | ||
"fs", | ||
"stream", | ||
"glob", | ||
"file-system", | ||
"ncp", | ||
"fast", | ||
"quick", | ||
"data", | ||
"content", | ||
"contents" | ||
], | ||
"dependencies": { | ||
"arrify": "^1.0.1", | ||
"cp-file": "^5.0.0", | ||
"globby": "^6.0.0", | ||
"nested-error-stacks": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "*", | ||
"rimraf": "^2.5.4", | ||
"tempfile": "^2.0.0", | ||
"xo": "*" | ||
} | ||
"name": "cpy", | ||
"version": "7.0.0", | ||
"description": "Copy files", | ||
"license": "MIT", | ||
"repository": "sindresorhus/cpy", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"maintainers": [ | ||
{ | ||
"name": "Michael Mayer", | ||
"email": "michael@schnittstabil.de", | ||
"url": "schnittstabil.de" | ||
} | ||
], | ||
"engines": { | ||
"node": ">=6" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"cpy-error.js", | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"copy", | ||
"cp", | ||
"cpy", | ||
"file", | ||
"files", | ||
"clone", | ||
"fs", | ||
"stream", | ||
"glob", | ||
"file-system", | ||
"ncp", | ||
"fast", | ||
"quick", | ||
"data", | ||
"content", | ||
"contents" | ||
], | ||
"dependencies": { | ||
"arrify": "^1.0.1", | ||
"cp-file": "^6.0.0", | ||
"globby": "^8.0.1", | ||
"nested-error-stacks": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "*", | ||
"rimraf": "^2.5.4", | ||
"tempfile": "^2.0.0", | ||
"xo": "*" | ||
} | ||
} |
@@ -27,5 +27,6 @@ # cpy [![Build Status](https://travis-ci.org/sindresorhus/cpy.svg?branch=master)](https://travis-ci.org/sindresorhus/cpy) | ||
cpy(['src/*.png', '!src/goat.png'], 'dist').then(() => { | ||
console.log('files copied'); | ||
}); | ||
(async () => { | ||
await cpy(['src/*.png', '!src/goat.png'], 'dist'); | ||
console.log('Files copied!'); | ||
})(); | ||
``` | ||
@@ -54,3 +55,3 @@ | ||
Options are passed to [cp-file](https://github.com/sindresorhus/cp-file#options) and [glob](https://github.com/isaacs/node-glob#options). | ||
Options are passed to [cp-file](https://github.com/sindresorhus/cp-file#options) and [globby](https://github.com/sindresorhus/globby#options). | ||
@@ -108,7 +109,7 @@ ##### cwd | ||
```js | ||
cpy(src, dst).on('progress', progress => { | ||
// … | ||
}).then(() => { | ||
// … | ||
}) | ||
(async () => { | ||
await cpy(source, destination).on('progress', progress => { | ||
// … | ||
}); | ||
})(); | ||
``` | ||
@@ -121,2 +122,3 @@ | ||
- [cp-file](https://github.com/sindresorhus/cp-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 | ||
@@ -123,0 +125,0 @@ |
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
7089
126
88
+ Added@mrmlnc/readdir-enhanced@2.2.1(transitive)
+ Added@nodelib/fs.stat@1.1.3(transitive)
+ Addedarr-diff@4.0.0(transitive)
+ Addedarr-flatten@1.1.0(transitive)
+ Addedarr-union@3.1.0(transitive)
+ Addedarray-unique@0.3.2(transitive)
+ Addedassign-symbols@1.0.0(transitive)
+ Addedatob@2.1.2(transitive)
+ Addedbase@0.11.2(transitive)
+ Addedbraces@2.3.2(transitive)
+ Addedcache-base@1.0.1(transitive)
+ Addedcall-me-maybe@1.0.2(transitive)
+ Addedclass-utils@0.3.6(transitive)
+ Addedcollection-visit@1.0.0(transitive)
+ Addedcomponent-emitter@1.3.1(transitive)
+ Addedcopy-descriptor@0.1.1(transitive)
+ Addedcp-file@6.2.0(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addeddecode-uri-component@0.2.2(transitive)
+ Addeddefine-property@0.2.51.0.02.0.2(transitive)
+ Addeddir-glob@2.0.0(transitive)
+ Addedexpand-brackets@2.1.4(transitive)
+ Addedextend-shallow@2.0.13.0.2(transitive)
+ Addedextglob@2.0.4(transitive)
+ Addedfast-glob@2.2.7(transitive)
+ Addedfill-range@4.0.0(transitive)
+ Addedfor-in@1.0.2(transitive)
+ Addedfragment-cache@0.2.1(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-value@2.0.6(transitive)
+ Addedglob-parent@3.1.0(transitive)
+ Addedglob-to-regexp@0.3.0(transitive)
+ Addedglobby@8.0.2(transitive)
+ Addedhas-value@0.3.11.0.0(transitive)
+ Addedhas-values@0.1.41.0.0(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedignore@3.3.10(transitive)
+ Addedis-accessor-descriptor@1.0.1(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedis-data-descriptor@1.0.1(transitive)
+ Addedis-descriptor@0.1.71.0.3(transitive)
+ Addedis-extendable@0.1.11.0.1(transitive)
+ Addedis-extglob@2.1.1(transitive)
+ Addedis-glob@3.1.04.0.3(transitive)
+ Addedis-number@3.0.0(transitive)
+ Addedis-plain-object@2.0.4(transitive)
+ Addedis-windows@1.0.2(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedisobject@2.1.03.0.1(transitive)
+ Addedkind-of@3.2.24.0.06.0.3(transitive)
+ Addedmake-dir@2.1.0(transitive)
+ Addedmap-cache@0.2.2(transitive)
+ Addedmap-visit@1.0.0(transitive)
+ Addedmerge2@1.4.1(transitive)
+ Addedmicromatch@3.1.10(transitive)
+ Addedmixin-deep@1.3.2(transitive)
+ Addedms@2.0.0(transitive)
+ Addednanomatch@1.2.13(transitive)
+ Addedobject-copy@0.1.0(transitive)
+ Addedobject-visit@1.0.1(transitive)
+ Addedobject.pick@1.3.0(transitive)
+ Addedpascalcase@0.1.1(transitive)
+ Addedpath-dirname@1.0.2(transitive)
+ Addedpath-type@3.0.0(transitive)
+ Addedpify@4.0.1(transitive)
+ Addedposix-character-classes@0.1.1(transitive)
+ Addedregex-not@1.0.2(transitive)
+ Addedrepeat-element@1.1.4(transitive)
+ Addedrepeat-string@1.6.1(transitive)
+ Addedresolve-url@0.2.1(transitive)
+ Addedret@0.1.15(transitive)
+ Addedsafe-regex@1.1.0(transitive)
+ Addedsemver@5.7.2(transitive)
+ Addedset-value@2.0.1(transitive)
+ Addedslash@1.0.0(transitive)
+ Addedsnapdragon@0.8.2(transitive)
+ Addedsnapdragon-node@2.1.1(transitive)
+ Addedsnapdragon-util@3.0.1(transitive)
+ Addedsource-map@0.5.7(transitive)
+ Addedsource-map-resolve@0.5.3(transitive)
+ Addedsource-map-url@0.4.1(transitive)
+ Addedsplit-string@3.1.0(transitive)
+ Addedstatic-extend@0.1.2(transitive)
+ Addedto-object-path@0.3.0(transitive)
+ Addedto-regex@3.0.2(transitive)
+ Addedto-regex-range@2.1.1(transitive)
+ Addedunion-value@1.0.1(transitive)
+ Addedunset-value@1.0.0(transitive)
+ Addedurix@0.1.0(transitive)
+ Addeduse@3.1.1(transitive)
- Removedcp-file@5.0.0(transitive)
- Removedglobby@6.1.0(transitive)
- Removedmake-dir@1.3.0(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedpify@2.3.0(transitive)
- Removedpinkie@2.0.4(transitive)
- Removedpinkie-promise@2.0.1(transitive)
Updatedcp-file@^6.0.0
Updatedglobby@^8.0.1