Skip to content

Commit

Permalink
return early
Browse files Browse the repository at this point in the history
Changed to return early instead of wrapping all
  • Loading branch information
laureysruben authored Jun 14, 2016
1 parent 6d3506e commit 7feb211
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,31 @@ module.exports = function (headerText, data) {
var template = data === false ? headerText : gutil.template(headerText, extend({ file: file, filename: filename }, data));
concat = new Concat(true, filename);

if (!fs.lstatSync(file.path).isDirectory()) {

if (file.isBuffer()) {
concat.add(null, new Buffer(template));
}

if (file.isStream()) {
var stream = through();
stream.write(new Buffer(template));
stream.on('error', this.emit.bind(this, 'error'));
file.contents = file.contents.pipe(stream);
this.push(file);
return cb();
}

// add sourcemap
concat.add(file.relative, file.contents, file.sourceMap);
if (fs.lstatSync(file.path).isDirectory()) {
// make sure the file goes through the next gulp plugin
this.push(file);

// tell the stream engine that we are done with this file
return cb();
}


if (file.isBuffer()) {
concat.add(null, new Buffer(template));
}

if (file.isStream()) {
var stream = through();
stream.write(new Buffer(template));
stream.on('error', this.emit.bind(this, 'error'));
file.contents = file.contents.pipe(stream);
this.push(file);
return cb();
}

// add sourcemap
concat.add(file.relative, file.contents, file.sourceMap);

// make sure streaming content is preserved
if (file.contents && !isStream(file.contents)) {
file.contents = concat.content;
Expand Down

0 comments on commit 7feb211

Please sign in to comment.