Comparing version 0.1.1 to 0.2.0
@@ -52,3 +52,2 @@ /* | ||
}); | ||
}; | ||
@@ -97,3 +96,3 @@ | ||
to = options.toHash[dir]; | ||
if (to && typeof to === 'string') { | ||
@@ -228,3 +227,3 @@ fs.stat(to, stack.add(function(err, s) { | ||
if (!dirs.length && !files.length) { | ||
return callback('no files to copy'); | ||
return callback(new Error('No files to copy')); | ||
} | ||
@@ -239,4 +238,7 @@ createDirs(dirs, to, options, function() { | ||
confirm(out, options, callback); | ||
} else if (!options.errors.length) { | ||
callback(null, out.sort()); | ||
} else { | ||
err = options.errors.length ? options.errors : null; | ||
err = new Error('Unable to copy directory' + (out.length ? ' entirely' : '')); | ||
err.list = options.errors; | ||
callback(err, out.sort()); | ||
@@ -253,3 +255,3 @@ } | ||
if (err) { | ||
return callback('From should be a directory'); | ||
return callback(new Error('From should be a directory')); | ||
} | ||
@@ -266,3 +268,3 @@ if (stat && stat.isDirectory()) { | ||
} else { | ||
callback('From should be a directory'); | ||
callback(new Error('From should be a directory')); | ||
} | ||
@@ -269,0 +271,0 @@ }); |
{ | ||
"name": "cpr", | ||
"description": "cp -R", | ||
"author": "Dav Glass <davglass@gmail.com>", | ||
"version": "0.1.1", | ||
"dependencies": { | ||
"graceful-fs": "~1.2.0", | ||
"rimraf": "~2.0.2", | ||
"mkdirp": "~0.3.4" | ||
}, | ||
"main": "./lib/index.js", | ||
"devDependencies": { | ||
"jshint": "~0.9.1", | ||
"yui-lint": "~0.1.0", | ||
"istanbul": "~0.1.8", | ||
"vows": "*" | ||
}, | ||
"contributors": [ | ||
{ "name": "Elijah Insua", "email": "tmpvar@gmail.com" } | ||
], | ||
"keywords": [ | ||
"copy", "recursive", "cp -r", "cp" | ||
], | ||
"scripts": { | ||
"pretest": "jshint --config ./node_modules/yui-lint/jshint.json ./lib/", | ||
"windows-test": "vows --spec ./tests/full.js", | ||
"test": "istanbul cover --print both -- vows --spec ./tests/full.js" | ||
}, | ||
"bugs": { "url" : "http://github.com/davglass/cpr/issues" }, | ||
"licenses":[ | ||
{ | ||
"type" : "BSD", | ||
"url" : "https://github.com/davglass/cpr/blob/master/LICENSE" | ||
} | ||
], | ||
"repository": { | ||
"type":"git", | ||
"url":"http://github.com/davglass/cpr.git" | ||
"name": "cpr", | ||
"description": "cp -R", | ||
"author": "Dav Glass <davglass@gmail.com>", | ||
"version": "0.2.0", | ||
"dependencies": { | ||
"graceful-fs": "~1.2.0", | ||
"rimraf": "~2.0.2", | ||
"mkdirp": "~0.3.4" | ||
}, | ||
"main": "./lib/index.js", | ||
"devDependencies": { | ||
"istanbul": "^0.2.9", | ||
"jshint": "~0.9.1", | ||
"vows": "*", | ||
"yui-lint": "~0.1.0" | ||
}, | ||
"contributors": [ | ||
{ | ||
"name": "Elijah Insua", | ||
"email": "tmpvar@gmail.com" | ||
} | ||
], | ||
"keywords": [ | ||
"copy", | ||
"recursive", | ||
"cp -r", | ||
"cp" | ||
], | ||
"scripts": { | ||
"pretest": "jshint --config ./node_modules/yui-lint/jshint.json ./lib/", | ||
"windows-test": "vows --spec ./tests/full.js", | ||
"test": "istanbul cover --print both -- vows --spec ./tests/full.js" | ||
}, | ||
"bugs": { | ||
"url": "http://github.com/davglass/cpr/issues" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "BSD", | ||
"url": "https://github.com/davglass/cpr/blob/master/LICENSE" | ||
} | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "http://github.com/davglass/cpr.git" | ||
} | ||
} |
@@ -24,21 +24,22 @@ CPR (cp -R) | ||
var cpr = require('cpr'); | ||
//or | ||
var cpr = require('cpr').cpr; //Back compat | ||
```js | ||
var cpr = require('cpr'); | ||
//or | ||
var cpr = require('cpr').cpr; //Back compat | ||
cpr('/path/from', '/path/to', { | ||
deleteFirst: true, //Delete "to" before | ||
overwrite: true, //If the file exists, overwrite it | ||
confirm: true //After the copy, stat all the copied files to make sure they are there | ||
}, function(errs, files) { | ||
//errs - Array of errors that occurred | ||
//files - List of files that we copied | ||
}); | ||
cpr('/path/from', '/path/to', { | ||
deleteFirst: true, //Delete "to" before | ||
overwrite: true, //If the file exists, overwrite it | ||
confirm: true //After the copy, stat all the copied files to make sure they are there | ||
}, function(err, files) { | ||
//err - The error if any (err.list might be available with an array of errors for more detailed information) | ||
//files - List of files that we copied | ||
}); | ||
cpr('/path/from', '/path/to', function(errs, files) { | ||
//errs - Array of errors that occurred | ||
//files - List of files that we copied | ||
}); | ||
cpr('/path/from', '/path/to', function(err, files) { | ||
//err - The error if any (err.list might be available with an array of errors for more detailed information) | ||
//files - List of files that we copied | ||
}); | ||
``` | ||
Options | ||
@@ -45,0 +46,0 @@ ------- |
@@ -79,7 +79,7 @@ var vows = require('vows'), | ||
'does not have ./out/1': function(topic) { | ||
assert.ok(topic.stat); //Should be an error | ||
assert.ok(topic.stat); // Should be an error | ||
}, | ||
'and threw an error': function(topic) { | ||
assert.ok(topic.err); //Should be an error | ||
assert.equal(topic.err, 'no files to copy'); | ||
assert(topic.err instanceof Error); // Should be an error | ||
assert.equal(topic.err.message, 'No files to copy'); | ||
} | ||
@@ -227,4 +227,4 @@ }, | ||
assert.isUndefined(topic.status); | ||
assert.ok(topic.err); | ||
assert.equal('From should be a directory', topic.err); | ||
assert(topic.err instanceof Error); | ||
assert.equal('From should be a directory', topic.err.message); | ||
} | ||
@@ -244,4 +244,4 @@ }, | ||
assert.isUndefined(topic.status); | ||
assert.ok(topic.err); | ||
assert.equal('From should be a directory', topic.err); | ||
assert(topic.err instanceof Error); | ||
assert.equal('From should be a directory', topic.err.message); | ||
} | ||
@@ -248,0 +248,0 @@ } |
Sorry, the diff of this file is not supported yet
22974
517
58