From e3a696c40fceeda0336be2523628cc8dab5becbf Mon Sep 17 00:00:00 2001 From: Adam Griffiths Date: Sun, 4 Aug 2013 19:12:53 +0100 Subject: [PATCH] Update wrench.js Fixes a bug (not sure if has been reported). `copyDirRecursive` calls itself from the `rmdirRecursive` callback when newDir exists. It should call itself with the original copyDirRecursive arguments, not the callback arguments. Also `fun.apply(thisArg, argsArray)` expects argsArray to be an array (see [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply)) but `arguments` is not an array (see [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope/arguments)) --- lib/wrench.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/wrench.js b/lib/wrench.js index a4e29b5..9c9b400 100644 --- a/lib/wrench.js +++ b/lib/wrench.js @@ -323,11 +323,12 @@ exports.rmdirRecursive = function rmdirRecursive(dir, failSilent, clbk){ * Note: Directories should be passed to this function without a trailing slash. */ exports.copyDirRecursive = function copyDirRecursive(srcDir, newDir, opts, clbk) { + var originalArguments = Array.prototype.slice.apply(arguments); fs.stat(newDir, function(err, newDirStat){ if(!err) { if(typeof opts !== 'undefined' && typeof opts !== 'function' && opts.forceDelete) return exports.rmdirRecursive(newDir, function(err){ - copyDirRecursive.apply(this, arguments); + copyDirRecursive.apply(this, originalArguments); }); else return clbk(new Error('You are trying to delete a directory that already exists. Specify forceDelete in an options object to override this.')); -- 2.39.5