more browserify refactoring. #158.

This commit is contained in:
Christopher Jeffrey 2015-07-26 17:48:22 -07:00
parent 956836a9ed
commit 18f3dfcc99
1 changed files with 8 additions and 9 deletions

View File

@ -17,22 +17,21 @@ var requires = widgets.reduce(function(out, name) {
}, '');
function transform(target) {
var tr = new Transform;
tr._transform = function(chunk, encoding, callback) {
var stream = new Transform;
stream._transform = function(chunk, encoding, callback) {
return callback(null, chunk);
};
tr._flush = function(callback) {
stream._flush = function(callback) {
if (target) {
tr.push(requires);
stream.push(requires);
}
return callback();
};
return tr;
return stream;
}
module.exports = function(file) {
if (path.basename(file) === 'widget.js') {
return transform(true);
}
return transform();
return path.basename(file) === 'widget.js'
? transform(true)
: transform();
};