gulp/plumb.js
function monkeyPatchPipe(stream) {
  while (!stream.hasOwnProperty('pipe')) {
    stream = Object.getPrototypeOf(stream)
    if (!stream) return null
  }

  let existingPipe = stream.pipe
  newPipe['$$monkey-patch'] = true
  return stream.pipe = newPipe

  /** Create new pipe copy of existing pipe */
  function newPipe() {
    let result = existingPipe.apply(this, arguments)
    result.setMaxListeners(0)
    if (!result.pipe['$$monkey-patch']) {
      monkeyPatchPipe(result)
    }

    return result.on('error', function(err) {
      gutil.log(gutil.colors.yellow(err))
      gutil.beep()
      this.emit('end')
    })
  }
}
function monkeyPatchPipe(stream) {
  while (!stream.hasOwnProperty('pipe')) {
    stream = Object.getPrototypeOf(stream)
    if (!stream) return null
  }

  let existingPipe = stream.pipe
  newPipe['$$monkey-patch'] = true
  return stream.pipe = newPipe

  /** Create new pipe copy of existing pipe */
  function newPipe() {
    let result = existingPipe.apply(this, arguments)
    result.setMaxListeners(0)
    if (!result.pipe['$$monkey-patch']) {
      monkeyPatchPipe(result)
    }

    return result.on('error', function(err) {
      gutil.log(gutil.colors.yellow(err))
      gutil.beep()
      this.emit('end')
    })
  }
}
function monkeyPatchPipe ( stream ) { while ( ! stream . hasOwnProperty ( 'pipe' ) ) { stream = Object . getPrototypeOf ( stream ) if ( ! stream ) return null } let existingPipe = stream . pipe newPipe [ '$$monkey-patch' ] = true return stream . pipe = newPipe /** Create new pipe copy of existing pipe */ function newPipe ( ) { let result = existingPipe . apply ( this , arguments ) result . setMaxListeners ( 0 ) if ( ! result . pipe [ '$$monkey-patch' ] ) { monkeyPatchPipe ( result ) } return result . on ( 'error' , function ( err ) { gutil . log ( gutil . colors . yellow ( err ) ) gutil . beep ( ) this . emit ( 'end' ) } ) } }
Monkey patch Gulp pipe to suppress errors in watch task
@param {object} pipe Gulp stream
Monkey patch Gulp pipe to suppress errors in watch task