Support returning multiple streams from gulp.task
See original GitHub issueCurrently when you are dealing with async streams, and want Gulp to know when the task is finished, you have 3 options:
- Accept a callback
- Return a stream
- Return a promise
Could this be extended to include Return an array of streams
, so the task is recognized as finished when all the streams are finished.
Currently I am using the following function as workaround:
function getStreamsFinishedPromise(streams){
var deferred = Q.defer();
var runningStreams = streams.length;
streams.forEach(function(stream){
stream.pipe(es.wait(function(){
runningStreams--;
if(runningStreams === 0){
deferred.resolve();
}
}));
});
return deferred.promise;
}
Issue Analytics
- State:
- Created 10 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
gulp.js - How do I return multiple streams back to main stream?
You can concatenate streams with merge-stream var gulp = require('gulp'); var merge = require('merge-stream'); gulp.task('bundle', ...
Read more >How to synchronize a Gulp-task that starts multiple streams in ...
The function incDoneCounter() is called at the end of every stream. It increments the variable doneCounter . If all streams have finished ...
Read more >gulp API docs
Returns a stream of Vinyl files that can be piped to plugins. ... gulp supports all options supported by node-glob and glob-stream except...
Read more >Working with Files | gulp.js
The stream produced by src() should be returned from a task to signal async completion, as mentioned in Creating Tasks. const { src,...
Read more >Browsersync + Gulp.js
Streams are supported in Browsersync, so you can call reload at specific ... sass into CSS & auto-inject into browsers gulp.task('sass', function() {...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@contra @sqs, the recipe does not work for me:
The first streams is never completed but killed halfway (only one jade view gets processed). Any ideas?
EDIT: found out that
var safeJade = combine(jade({pretty: true}));
is the culprit.Closing this - use the recipe https://github.com/gulpjs/gulp/blob/master/docs/recipes/using-multiple-sources-in-one-task.md