diff --git a/lib/copy-sync/copy-sync.js b/lib/copy-sync/copy-sync.js index 8168deee..113e512d 100644 --- a/lib/copy-sync/copy-sync.js +++ b/lib/copy-sync/copy-sync.js @@ -23,14 +23,16 @@ function copySync (src, dest, options) { var destFolderExists = fs.existsSync(destFolder) var performCopy = false - if (stats.isFile()) { - if (options.filter instanceof RegExp) performCopy = options.filter.test(src) - else if (typeof options.filter === 'function') performCopy = options.filter(src) + if (options.filter instanceof RegExp) performCopy = options.filter.test(src) + else if (typeof options.filter === 'function') performCopy = options.filter(src) + + if (!performCopy) { + return; + } - if (performCopy) { - if (!destFolderExists) mkdir.mkdirsSync(destFolder) - copyFileSync(src, dest, {clobber: options.clobber, preserveTimestamps: options.preserveTimestamps}) - } + if (stats.isFile()) { + if (!destFolderExists) mkdir.mkdirsSync(destFolder) + copyFileSync(src, dest, {clobber: options.clobber, preserveTimestamps: options.preserveTimestamps}) } else if (stats.isDirectory()) { if (!fs.existsSync(dest)) mkdir.mkdirsSync(dest) var contents = fs.readdirSync(src)