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

cpr

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cpr - npm Package Compare versions

Comparing version 0.4.3 to 1.0.0

28

lib/index.js

@@ -24,2 +24,3 @@ /*

fs.stat(from, stack.add(function(err, stat) {
/*istanbul ignore next*/
if (err) {

@@ -37,2 +38,3 @@ return errors.push(err);

options.toHash[base] = path.join(options.to, path.relative(options.from, base));
/*istanbul ignore next*/
if (err) {

@@ -43,2 +45,3 @@ return errors.push(err);

getTree(base, options, stack.add(function(errs, tree) {
/*istanbul ignore next*/
if (errs && errs.length) {

@@ -49,9 +52,8 @@ errs.forEach(function(item) {

}
if (tree && tree.length) {
tree.forEach(function(item) {
results[item] = true;
});
}
//tree is always an Array
tree.forEach(function(item) {
results[item] = true;
});
}));
} else if (stat.isFile()) {
} else {
results[base] = true;

@@ -116,14 +118,7 @@ }

fs.stat(to, stack.add(function(err, s) {
if (s && s.isDirectory()) {
if (options.overwrite) {
rimraf(to, stack.add(function() {
mkdirp(to, stat.mode, stack.add(function(err) {
if (err) {
options.errors.push(err);
}
}));
}));
}
if (s && !s.isDirectory()) {
options.errors.push(new Error(to + ' exists and is not a directory, can not create'));
} else {
mkdirp(to, stat.mode, stack.add(function(err) {
/*istanbul ignore next*/
if (err) {

@@ -155,2 +150,3 @@ options.errors.push(err);

onError = function (e) {
/*istanbul ignore next*/
err = e;

@@ -157,0 +153,0 @@ };

@@ -5,3 +5,3 @@ {

"author": "Dav Glass <davglass@gmail.com>",
"version": "0.4.3",
"version": "1.0.0",
"dependencies": {

@@ -14,6 +14,6 @@ "graceful-fs": "~4.1.2",

"devDependencies": {
"istanbul": "~0.3.5",
"jshint": "~0.9.1",
"istanbul": "~0.4.0",
"jshint": "~2.8.0",
"vows": "~0.8.1",
"yui-lint": "~0.1.0"
"yui-lint": "~0.2.0"
},

@@ -38,3 +38,4 @@ "contributors": [

"windows-test": "vows --spec ./tests/full.js",
"test": "istanbul cover --print both -- vows --spec ./tests/full.js"
"test": "istanbul cover --print both -- vows --spec ./tests/full.js",
"posttest": "istanbul check-coverage --statement 98 --branch 95 --function 95 --line 98"
},

@@ -41,0 +42,0 @@ "bugs": {

@@ -304,7 +304,44 @@ var vows = require('vows'),

assert.ok(stat.isDirectory());
}
},
"should not delete existing folders in out dir": {
topic: function() {
var mkdirp = require('mkdirp');
mkdirp.sync(path.join(to, 'empty-src', 'a'));
mkdirp.sync(path.join(to, 'empty-dest', 'b'));
cpr(path.join(to, 'empty-src'), path.join(to, 'empty-dest'), { overwrite: true }, this.callback);
},
'has ./out/empty-dest': function(topic) {
var stat = fs.statSync(path.join(to, 'empty-dest'));
assert.ok(stat.isDirectory());
var dirs = fs.readdirSync(path.join(to, 'empty-dest'));
assert.equal(dirs[0], 'a');
assert.equal(dirs[1], 'b');
}
},
"should return an error if a directory is to write over an existing file with the same name": {
topic: function() {
var mkdirp = require('mkdirp');
mkdirp.sync(path.join(to, 'empty-src2', 'a'));
mkdirp.sync(path.join(to, 'empty-dest2'));
fs.writeFileSync(path.join(to, 'empty-dest2', 'a'), 'FILE');
cpr(path.join(to, 'empty-src2'), path.join(to, 'empty-dest2'), { overwrite: true }, function(e, d) {
this.callback(null, {
errs: e,
data: d
});
}.bind(this));
},
'has ./out/empty-dest': function(topic) {
var stat = fs.statSync(path.join(to, 'empty-dest2'));
assert.ok(stat.isDirectory());
assert.ok(topic.errs);
assert.ok(topic.errs.list);
assert.ok(topic.errs.list[0]);
assert.ok(topic.errs.list[0].message.match(/exists and is not a directory, can not create/));
}
},
"should copy one file": {
topic: function() {
cpr(__filename, path.join(to, 'one-file-test/'), {overwrite: true}, this.callback);
cpr(__filename, path.join(to, 'one-file-test/'), { overwrite: true }, this.callback);
},

@@ -330,6 +367,6 @@ "should copy one file": function(topic) {

}
},
},
}
}
};
vows.describe('CPR Tests').addBatch(tests).export(module);

Sorry, the diff of this file is not supported yet

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