[CB-4901] Removed custom modified wrench + wrench bump to 1.4.4

Reviewed by Jeffrey Heifitz <jheifitz@blackberry.com>
Tested by Tracy Li <tli@blackberry.com>
diff --git a/blackberry10/bin/templates/project/cordova/lib/file-manager.js b/blackberry10/bin/templates/project/cordova/lib/file-manager.js
index 8695a9b..596102f 100755
--- a/blackberry10/bin/templates/project/cordova/lib/file-manager.js
+++ b/blackberry10/bin/templates/project/cordova/lib/file-manager.js
@@ -60,21 +60,18 @@
 
 function copyDirContents(from, to) {
     var files = wrench.readdirSyncRecursive(from),
-        bbwpignore,
         bbwpignoreFile = path.join(from, conf.BBWP_IGNORE_FILENAME),
-        toBeIgnored = [];
+        bbwpignore,
+        ignoreFiles = conf.BBWP_IGNORE_FILENAME;
 
     if (fs.existsSync(bbwpignoreFile)) {
         bbwpignore = new BBWPignore(bbwpignoreFile, files);
-
-        bbwpignore.matchedFiles.forEach(function (i) {
-            toBeIgnored.push(from + "/" + i);
-        });
-        toBeIgnored.push(from + "/" + conf.BBWP_IGNORE_FILENAME); //add the .bbwpignore file to the ignore list
+        bbwpignore.matchedFiles.push(conf.BBWP_IGNORE_FILENAME); //add the .bbwpignore file to the ignore list
+        ignoreFiles = bbwpignore.matchedFiles.join("|");
     }
-    wrench.copyDirSyncRecursive(from, to, {preserve: true}, function (file) {
-        return toBeIgnored.indexOf(file) === -1;
-    });
+
+
+    wrench.copyDirSyncRecursive(from, to, {preserve: true, whitelist: false, filter: new RegExp(ignoreFiles, "g")});
 }
 
 function prepare(session) {
diff --git a/blackberry10/bin/templates/project/cordova/lib/packager.js b/blackberry10/bin/templates/project/cordova/lib/packager.js
index 1591a0c..ccbbeff 100644
--- a/blackberry10/bin/templates/project/cordova/lib/packager.js
+++ b/blackberry10/bin/templates/project/cordova/lib/packager.js
@@ -14,8 +14,6 @@
  * limitations under the License.
  */
 
-require('./../third_party/wrench/wrench');
-
 var path = require("path"),
     wrench = require("wrench"),
     cmdline = require("./cmdline"),
diff --git a/blackberry10/bin/templates/project/cordova/third_party/wrench/wrench.js b/blackberry10/bin/templates/project/cordova/third_party/wrench/wrench.js
deleted file mode 100644
index 8c3d746..0000000
--- a/blackberry10/bin/templates/project/cordova/third_party/wrench/wrench.js
+++ /dev/null
@@ -1,78 +0,0 @@
-/*  wrench.js
- *
- *  A collection of various utility functions I've found myself in need of
- *  for use with Node.js (http://nodejs.org/). This includes things like:
- *
- *  - Recursively deleting directories in Node.js (Sync, not Async)
- *  - Recursively copying directories in Node.js (Sync, not Async)
- *  - Recursively chmoding a directory structure from Node.js (Sync, not Async)
- *  - Other things that I'll add here as time goes on. Shhhh...
- *
- *  ~ Ryan McGrath (ryan [at] venodesigns.net)
- */
-
-/* This file is originally licensed under https://raw.github.com/ryanmcgrath/wrench-js/master/LICENSE
- * This code has been copied from https://raw.github.com/ryanmcgrath/wrench-js and modified
- * add the functionality for a callback to the copyDirSyncRecursive method.
- * Modifications have been clearly marked.
- * The callback acts like a filter and you must return true/false from it to include/exclude a file
- */
-
-var wrench = require('wrench'),
-    fs = require("fs"),
-    _path = require("path");
-/*  wrench.copyDirSyncRecursive("directory_to_copy", "new_directory_location", opts);
- *
- *  Recursively dives through a directory and moves all its files to a new location. This is a
- *  Synchronous function, which blocks things until it's done. If you need/want to do this in
- *  an Asynchronous manner, look at wrench.copyDirRecursively() below.
- *
- *  Note: Directories should be passed to this function without a trailing slash.
- */
-wrench.copyDirSyncRecursive = function(sourceDir, newDirLocation, opts, callback) {
-
-    /**************************Modification*****************************************/
-    if (typeof opts === "function") {
-        callback = opts;
-        opts = {};
-    }
-    /**************************Modification End*****************************************/
-
-    if (!opts || !opts.preserve) {
-        try {
-            if(fs.statSync(newDirLocation).isDirectory()) wrench.rmdirSyncRecursive(newDirLocation);
-        } catch(e) { }
-    }
-
-    /*  Create the directory where all our junk is moving to; read the mode of the source directory and mirror it */
-    var checkDir = fs.statSync(sourceDir);
-    try {
-        fs.mkdirSync(newDirLocation, checkDir.mode);
-    } catch (e) {
-        //if the directory already exists, that's okay
-        if (e.code !== 'EEXIST') throw e;
-    }
-
-    var files = fs.readdirSync(sourceDir);
-
-    for(var i = 0; i < files.length; i++) {
-        var currFile = fs.lstatSync(sourceDir + "/" + files[i]);
-        /**************************Modified to add if statement*****************************************/
-        if (callback && !callback(sourceDir + "/" + files[i], currFile)) {
-            continue;
-        }
-        if(currFile.isDirectory()) {
-            /*  recursion this thing right on back. */
-            wrench.copyDirSyncRecursive(sourceDir + "/" + files[i], newDirLocation + "/" + files[i], opts, callback);
-        } else if(currFile.isSymbolicLink()) {
-            var symlinkFull = fs.readlinkSync(sourceDir + "/" + files[i]);
-            fs.symlinkSync(symlinkFull, newDirLocation + "/" + files[i]);
-        } else {
-            /*  At this point, we've hit a file actually worth copying... so copy it on over. */
-            var contents = fs.readFileSync(sourceDir + "/" + files[i]);
-            fs.writeFileSync(newDirLocation + "/" + files[i], contents);
-        }
-    }
-};
-
-
diff --git a/blackberry10/package.json b/blackberry10/package.json
index 2185b89..3759ff9 100644
--- a/blackberry10/package.json
+++ b/blackberry10/package.json
@@ -24,7 +24,7 @@
     "zip": "0.0.6",
     "xml2js": "0.1.13",
     "validator": "0.4.1",
-    "wrench": "1.3.9",
+    "wrench": "1.4.4",
     "shelljs":"0.1.3",
     "elementtree": "0.1.5",
     "prompt": "0.2.11",