'use strict'; const stream = require("stream"); const combiner = require("stream-combiner2"); const plumber = require("gulp-plumber"); const namedLog = require("gulp-named-log"); const util = require("util"); module.exports = function(name, streams, options = {}) { let logger = namedLog(name, options.logger); let streamList = streams.concat([ logger.stream() ]); /* We need to patch in the `pipe` handler manually, as this monkeypatch doesn't * carry over to Duplex streams that are created by `stream-combiner2`. The * `stream-combiner2` library will take care of re-emitting the errors on the * combined stream, so we don't need `gulp-plumber` in our actual pipeline. */ let plumberStream = plumber(function(err) { logger.error(err); /* Ensure that the task finishes, so as to not break `gulp.watch`. */ this.emit("end"); }); let combinedStream = combiner.obj(streamList); plumberStream.pipe(combinedStream); return combinedStream; }