Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cpy

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cpy - npm Package Compare versions

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 @@ };

{
"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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc