gulp.task('test', function() {
var streamsArr = [];
for (var stream, i = 1; i < 5; i++) {
stream = gulp.src(path.join(__dirname, 'test' + i, '**/*'))
.pipe(through.obj(function(file, enc, callback) {
setTimeout(function() {
callback(null, file);
}, Math.ceil(Math.random()*100));
}))
.pipe(require('gulp-concat')('script.js'))
.on('end', (function(i) {
console.log('end of the stream ' + i);
}).bind(null, i));
streamsArr.push(stream);
}
require('gulp-merge')(streamsArr) //or stream-series, or merge-stream, etc.
.pipe(through.obj(function(file, enc, callback){
console.log('merged stream transform:', path.relative(__dirname, file.path));
callback(null, file);
}, function(callback) {
console.log('merged stream flush');
callback();
}))
.on('end', function() {
console.log('end of the merged stream');
});
});
console:
end of the stream 4
end of the stream 3
merged stream transform: test1\script.js
end of the stream 1
merged stream transform: test2\script.js
end of the stream 2
Somehow, part of a stream is lost. Also did not work flush and end event of merged stream.
Windows, node.js v 0.12.2
File structure:
gulpfile.js:
console:
Somehow, part of a stream is lost. Also did not work flush and
end
event of merged stream.