mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-21 02:29:23 +00:00
feature(ncp) add stopedOnError
This commit is contained in:
parent
795b1c3d64
commit
a267eac253
1 changed files with 19 additions and 15 deletions
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue