From 2628e88075fe98f9573d4776c0e5bc77c7c81b33 Mon Sep 17 00:00:00 2001 From: Ryan McGrath Date: Fri, 9 Nov 2012 10:10:15 -0500 Subject: [PATCH] Fixes #39 --- lib/wrench.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/wrench.js b/lib/wrench.js index 247874a..4c8fb9e 100644 --- a/lib/wrench.js +++ b/lib/wrench.js @@ -184,11 +184,13 @@ exports.copyDirSyncRecursive = function(sourceDir, newDirLocation, opts) { for(var i = 0; i < files.length; i++) { // ignores all files or directories which match the RegExp in opts.filter - if(!opts.whitelist && opts.filter && files[i].match(opts.filter)) continue; - // if opts.whitelist is true every file or directory which doesn't match opts.filter will be ignored - if(opts.whitelist && opts.filter && !files[i].match(opts.filter)) continue; - if (opts.excludeHiddenUnix && /^\./.test(files[i])) continue; - + if(typeof opts !== 'undefined') { + if(!opts.whitelist && opts.filter && files[i].match(opts.filter)) continue; + // if opts.whitelist is true every file or directory which doesn't match opts.filter will be ignored + if(opts.whitelist && opts.filter && !files[i].match(opts.filter)) continue; + if (opts.excludeHiddenUnix && /^\./.test(files[i])) continue; + } + var currFile = fs.lstatSync(sourceDir + "/" + files[i]); if(currFile.isDirectory()) { /* recursion this thing right on back. */