Skip to content

Commit

Permalink
normalize copy plugin. Fixes componentjs#166
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Zhang committed Feb 19, 2014
1 parent 3ec69dc commit 4bceae8
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion lib/plugins/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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){
Expand All @@ -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());
}

0 comments on commit 4bceae8

Please sign in to comment.