'use strict'; var stream = require("stream"); var combiner = require("stream-combiner2"); var plumber = require("gulp-plumber"); var namedLog = require("gulp-named-log"); var util = require("util"); module.exports = function (name, streams) { var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; var logger = namedLog(name, options.logger); var 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. */ var plumberStream = plumber(function (err) { logger.error(err); /* Ensure that the task finishes, so as to not break `gulp.watch`. */ this.emit("end"); }); var combinedStream = combiner.obj(streamList); plumberStream.pipe(combinedStream); return combinedStream; };