SSCCE:
gulp.task('foo', [], function() {
var barFiles = getBarFiles();
var bazFiles = getBazFiles();
var barStream, bazStream;
if (barFiles && barFiles.length > 0) {
barStream = gulp.src(barFiles);
}
if (bazStream && bazStream.length > 0) {
bazStream = gulp.src(bazStream);
}
return eventStream
.merge(barStream, bazStream)
.pipe(g.concat('bar-and-baz'))
.pipe(gulp.dest('./foo-output/'));
});
getBarFiles()
or getBazFiles()
may return an empty array,
which is not allowed by gulp.src()
: Error: Invalid glob argument
,
hence the need to wrap the creation of the stream with an if
condition.
So the question is, how do I create an empty stream, so that it can be merged with the other empty on non-empty stream?
gulp-util.noop
to create an empty stream. – Lampertgulp.src
to pipe data through? – Duckworth