/* eslint import/no-extraneous-dependencies: 0 */

const notify = require('gulp-notify');
const gutil  = require('gulp-util');


function reportError(error) {
  // Console error
  let report = '\n';
  const chalk = gutil.colors.red.bold;
  let notifyMessage = '';

  if (error.plugin) {
    report += `${chalk('PLUGIN:')} [' ${error.plugin} ']\n`;
  }

  if (error.message) {
    report += `${chalk('ERROR:')} ${error.message}\n`;
  }

  if (!error.message) {
    report += `${chalk('ERROR:')} ${error.toString()}\n`;
  }

  gutil.log(gutil.colors.red(report));

  // Notification
  if (error.line && error.column) {
    notifyMessage += `LINE ${error.line}:${error.column} -- `;
  }

  if (error.file) {
    notifyMessage += `FILE ${error.file}`;
  }

  notify({
    title: `FAIL: ${error.plugin}`,
    message: `${notifyMessage} See console.`,
    sound: false, // See: https://github.com/mikaelbr/node-notifier#all-notification-options-with-their-defaults
  }).write(error);

  // System beep
  gutil.beep();

  if (typeof this.emit === 'function') { this.emit('end'); }
}

module.exports = reportError;

@@ -121,16 +121,108 @@
 til');%0A%0A
+// Taken from here https://github.com/mikaelbr/gulp-notify/issues/81#issuecomment-268852774%0A
 %0Afunctio
@@ -952,103 +952,8 @@
 lse,
- // See: https://github.com/mikaelbr/node-notifier#all-notification-options-with-their-defaults
 %0A  %7D

add credit to error handling code