feature(ncp) add stopedOnError

This commit is contained in:
coderaiser 2014-06-23 03:45:36 -04:00
parent 795b1c3d64
commit a267eac253

View file

@ -16,7 +16,8 @@ function ncp (source, dest, options, callback) {
options = {};
}
var basePath = process.cwd(),
var stopedOnError = false,
basePath = process.cwd(),
currentPath = path.resolve(basePath, source),
targetPath = path.resolve(basePath, dest),
filter = options.filter,
@ -206,21 +207,24 @@ function ncp (source, dest, options, callback) {
}
function onError(err) {
if (options.stopOnError) {
return cback(err);
}
else if (!errs && options.errs) {
errs = fs.createWriteStream(options.errs);
}
else if (!errs) {
errs = [];
}
if (typeof errs.write === 'undefined') {
errs.push(err);
}
else {
errs.write(err.stack + '\n\n');
if (!stopedOnError) {
if (options.stopOnError) {
return cback(err);
}
else if (!errs && options.errs) {
errs = fs.createWriteStream(options.errs);
}
else if (!errs) {
errs = [];
}
if (typeof errs.write === 'undefined') {
errs.push(err);
}
else {
errs.write(err.stack + '\n\n');
}
}
return cb();
}