Skip to content

Commit

Permalink
Emit 'end' when complete
Browse files Browse the repository at this point in the history
  • Loading branch information
sublimino committed Jun 17, 2014
1 parent 3664909 commit 4af6b82
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,34 @@ module.exports = function(opt) {
.pipe(gulpless())
.pipe(through(function (file) {

self.emit('data', file);
}));
self.emit('data', file);
}).on('end', function() {
emitEnd(self);
}));

gulp.src(path.join(opt.templateDirectory, '/**/*.js'))
.pipe(through(function (file) {

self.emit('data', file);
}));

self.emit('data', file);
}).on('end', function() {
emitEnd(self);
}));
});

}

// duplicate of underscore's _.after() function http://underscorejs.org/docs/underscore.html#section-76
var underscoreAfter = function underscoreAfter(times, func) {
return function() {
if (--times < 1) {
return func.apply(this, arguments);
}
};
};

var emitEnd = underscoreAfter(2, function emitEnd(self) {
self.emit('end');
});

function jsonSections(sections) {
return sections.map(function(section) {
return {
Expand Down

0 comments on commit 4af6b82

Please sign in to comment.