New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cprf

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cprf - npm Package Compare versions

Comparing version 0.1.2 to 1.0.0

62

cprf.js

@@ -5,13 +5,9 @@ var fs = require('fs');

function mkdir (dir, done) {
fs.exists(dir, function (exists) {
if (exists) return done();
fs.mkdir(dir, function (err) {
if (err) return done(new Error(err));
done();
});
});
}
var DEFAULT_LIMIT = 24;
function copy (src, dest, done) {
module.exports = copy;
function copy (src, dest, done, limit) {
limit = limit || DEFAULT_LIMIT;
fs.lstat(src, function (err, stats) {

@@ -25,7 +21,4 @@ if (err) return done(new Error(err));

if (err) return done(new Error(err));
async.each(files, function(filename, done) {
copy(
path.join(src, filename),
path.join(dest, filename),
done);
async.eachLimit(files, limit, function (file, done) {
copy(path.join(src, file), path.join(dest, file), done, limit);
}, done);

@@ -45,16 +38,33 @@ });

var fin = fs.createReadStream(src);
var fout = fs.createWriteStream(dest);
copyFile(src, dest, function (err) {
if (err) return done(err);
fs.chmod(dest, stats.mode, done);
});
fin.on('end', function () {
fs.chmod(dest, stats.mode, function (err) {
if (err) return done(new Error(err));
done();
});
});
fin.on('error', done);
fin.pipe(fout);
});
}
module.exports = copy;
function mkdir (dir, done) {
fs.exists(dir, function (exists) {
return exists ? done() : fs.mkdir(dir, done);
});
}
function copyFile (src, dest, done) {
var doneCalled = false;
var fin = fs.createReadStream(src);
fin.on('error', finish);
var fout = fs.createWriteStream(dest);
fout.on('error', finish);
fout.on('close', finish);
fin.pipe(fout);
function finish (err) {
if (doneCalled) return;
doneCalled = true;
done(err);
}
}
{
"name": "cprf",
"version": "0.1.2",
"version": "1.0.0",
"description": "Recursively copy files and directories",

@@ -11,4 +11,9 @@ "main": "cprf.js",

"type": "git",
"url": "https://www.github.com/lxe/cprf"
"url": "https://github.com/lxe/cprf.git"
},
"homepage": "https://github.com/lxe/cprf",
"bugs": {
"url": "https://github.com/lxe/cprf/issues",
"email": "lxe@lxe.co"
},
"keywords": [

@@ -24,4 +29,4 @@ "copy",

"dependencies": {
"async": "0.9.0",
"rimraf": "2.2.8"
"async": "~0.9.x",
"rimraf": "~2.2.x"
},

@@ -31,2 +36,2 @@ "devDependencies": {

}
}
}

@@ -13,2 +13,3 @@ # cprf

- Fully asynchronous
- Limits file descriptors to 24 (per invocation)
- Attempts to call back with meaningful errors

@@ -32,3 +33,5 @@ - Tests!

}
});
}, 24);
/// where '24' is the asynchronous concurrency limit.
```

@@ -38,2 +41,6 @@

#### 1.0.0
- Add default/adjustable concurrency limit
#### 0.1.2

@@ -40,0 +47,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