From 35345a330fedfd2aaab54471d1db9cbcdc087a94 Mon Sep 17 00:00:00 2001 From: JP Richardson Date: Wed, 28 Jan 2015 02:16:40 -0600 Subject: [PATCH] lib/_copy: fixed nasty multiple callback `fs.copy()` bug. Closes #98 --- CHANGELOG.md | 1 + lib/_copy.js | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6c0133e..7d797eaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - bugfix `fs.move()` into itself. Closes #104 - bugfix `fs.move()` moving directory across device. Closes #108 - added coveralls support +- bugfix: nasty multiple callback `fs.copy()` bug. Closes #98 0.15.0 / 2015-01-21 ------------------- diff --git a/lib/_copy.js b/lib/_copy.js index 1168430b..76f440b4 100644 --- a/lib/_copy.js +++ b/lib/_copy.js @@ -82,15 +82,16 @@ function ncp (source, dest, options, callback) { var target = file.name.replace(currentPath, targetPath) isWritable(target, function (writable) { if (writable) { - return copyFile(file, target) - } - if(clobber) { - rmFile(target, function () { - copyFile(file, target) - }) + copyFile(file, target) + } else { + if(clobber) { + rmFile(target, function () { + copyFile(file, target) + }) + } else { + cb() + } } - - return cb() }) }