Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions lib/plugins/copy.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

/**
* Module dependencies.
*/

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;
Expand Down Expand Up @@ -41,7 +41,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 +62,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
: basename(conf.path());
}