From 4046e486fe5d931e66df6146b2bbdb0918f08c18 Mon Sep 17 00:00:00 2001 From: Krzysztof Antczak Date: Sun, 12 Jan 2014 21:12:46 +0100 Subject: [PATCH 1/2] Wrench instead fs-extra, to allow recursive copies with symlinks --- lib/copy.js | 11 ++++++++--- lib/setup.js | 9 +++++++-- package.json | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/copy.js b/lib/copy.js index 8fa8bc8..911e97a 100644 --- a/lib/copy.js +++ b/lib/copy.js @@ -8,7 +8,7 @@ /** * Dependencies */ -var extra = require('fs-extra'), +var wrench = require('wrench'), fs = require('fs'); /** @@ -28,8 +28,13 @@ module.exports = function (template, name, callback) { if (!fs.existsSync(source)) return callback('Template not found.'); if (fs.existsSync(destination)) return callback('Path already exists.'); - // Copy - extra.copy(source, destination, function (err) { + wrench.copyDirSyncRecursive(source, destination, { + forceDelete: false, // Whether to overwrite existing directory or not + excludeHiddenUnix: false, // Whether to copy hidden Unix files or not (preceding .) + preserveFiles: false, // If we're overwriting something and the file already exists, keep the existing + inflateSymlinks: true, // Whether to follow symlinks or not when copying files + }, function(err) + { callback(err, destination); }); }; \ No newline at end of file diff --git a/lib/setup.js b/lib/setup.js index 0ec346b..82c3d90 100644 --- a/lib/setup.js +++ b/lib/setup.js @@ -9,7 +9,7 @@ * Dependencies */ var colors = require('colors'), - extra = require('fs-extra'), + wrench = require('wrench'), fs = require('fs'); /** @@ -21,6 +21,11 @@ module.exports = function (callback) { fs.exists(target, function (exists) { if (exists) console.log('Re-initalizing default templates...'.yellow); - extra.copy(source, target, callback); + wrench.copyDirSyncRecursive(source, target, { + forceDelete : true, // Whether to overwrite existing directory or not + excludeHiddenUnix: false, // Whether to copy hidden Unix files or not (preceding .) + preserveFiles : false, // If we're overwriting something and the file already exists, keep the existing + inflateSymlinks : true // Whether to follow symlinks or not when copying files + }, callback); }); }; \ No newline at end of file diff --git a/package.json b/package.json index 6647c33..9c3b422 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "async": "~0.2.9", "colors": "~0.6.2", "findit": "~0.1.2", - "fs-extra": "~0.6.3", + "wrench": "~1.5.4" "prompt": "~0.2.11", "optimist": "~0.6.0", "replace": "~0.2.7" From c8e0b068432c6cea8bb326d2138e7241e2e0452d Mon Sep 17 00:00:00 2001 From: Krzysztof Antczak Date: Sun, 12 Jan 2014 21:21:01 +0100 Subject: [PATCH 2/2] fixed missing comma --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9c3b422..23c49db 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "async": "~0.2.9", "colors": "~0.6.2", "findit": "~0.1.2", - "wrench": "~1.5.4" + "wrench": "~1.5.4", "prompt": "~0.2.11", "optimist": "~0.6.0", "replace": "~0.2.7"