From 4bceae8d7e89bc83d7514d49d0d65c4835c636ab Mon Sep 17 00:00:00 2001 From: Aaron Zhang Date: Wed, 19 Feb 2014 00:54:21 -0500 Subject: [PATCH 1/3] normalize copy plugin. Fixes #166 --- lib/plugins/copy.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/plugins/copy.js b/lib/plugins/copy.js index aef1ee2..d5fd1cc 100644 --- a/lib/plugins/copy.js +++ b/lib/plugins/copy.js @@ -11,6 +11,7 @@ var join = require('path').join; var mkdirp = require('mkdirp'); var Batch = require('batch'); var cp = require('cp'); +var basename = require('path').basename; /** * Ops @@ -41,7 +42,7 @@ module.exports = function(type, dest, opts){ build.each(type, function(file, conf){ batch.push(function(done){ var src = conf.path(file); - var base = conf.name.replace('/', '-'); + var base = normalize(conf, build.components); var to = join(dest, base, file); var dir = dirname(to); exists(to, function(exist){ @@ -62,3 +63,19 @@ module.exports = function(type, dest, opts){ batch.end(done); }; }; + + +/** + * Normalize conf name. + * + * @param {Object} conf + * @param {Array} list + * @return {String} + * @api private + */ + +function normalize(conf, list){ + return conf == list[0] + ? conf.name + : require('path').basename(conf.path()); +} \ No newline at end of file From 7cd0d7d248cd918348ffd631f2efd24deeec215a Mon Sep 17 00:00:00 2001 From: aaronz8 Date: Mon, 10 Mar 2014 15:17:01 -0400 Subject: [PATCH 2/3] Removed redundant require --- lib/plugins/copy.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/plugins/copy.js b/lib/plugins/copy.js index d5fd1cc..bc9aa60 100644 --- a/lib/plugins/copy.js +++ b/lib/plugins/copy.js @@ -1,4 +1,3 @@ - /** * Module dependencies. */ @@ -11,7 +10,6 @@ var join = require('path').join; var mkdirp = require('mkdirp'); var Batch = require('batch'); var cp = require('cp'); -var basename = require('path').basename; /** * Ops @@ -78,4 +76,4 @@ function normalize(conf, list){ return conf == list[0] ? conf.name : require('path').basename(conf.path()); -} \ No newline at end of file +} From 0c3beacc17ededa08a1acdb2094976130730b4bc Mon Sep 17 00:00:00 2001 From: aaronz8 Date: Mon, 10 Mar 2014 15:31:42 -0400 Subject: [PATCH 3/3] Made it prettier moved require('path').basename outside of the function --- lib/plugins/copy.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/plugins/copy.js b/lib/plugins/copy.js index bc9aa60..4c3c156 100644 --- a/lib/plugins/copy.js +++ b/lib/plugins/copy.js @@ -4,6 +4,7 @@ var debug = require('debug')('component:builder:copy'); var dirname = require('path').dirname; +var basename = require('path').basename; var symlink = require('fs').symlink; var exists = require('fs').exists; var join = require('path').join; @@ -75,5 +76,5 @@ module.exports = function(type, dest, opts){ function normalize(conf, list){ return conf == list[0] ? conf.name - : require('path').basename(conf.path()); + : basename(conf.path()); }