diff --git a/gulp/error-formatter.js b/gulp/error-formatter.js index 1430694..25979ca 100644 --- a/gulp/error-formatter.js +++ b/gulp/error-formatter.js @@ -26,6 +26,7 @@ var beeper = require('beeper'); var color = require('ansi-colors'); var minimist = require('minimist'); var notify = require('gulp-notify'); +var path = require('path'); var PluginError = require('plugin-error'); @@ -48,53 +49,58 @@ module.exports = function (error) { // [log] Uncomment to show the full error object //console.log(error); + var report = ['\n']; + var notifyMessage = ''; + var notifyTitle = ''; + // ---------------------------------------------- // Normalize error responses - var report = ['\n']; - var notifyMessage = ''; - if (error.plugin == 'gulp-eslint') { + notifyTitle = 'Lint JS'; + notifyMessage = path.basename(error.fileName) + '\n' + error.lineNumber; + report.push(color.red('Plugin: ') + error.plugin + '\n'); report.push(color.red('File: ') + error.fileName + '\n'); report.push(color.red('Line: ') + error.lineNumber + '\n'); report.push(color.red('Note: ') + error.message + '\n'); - - notifyMessage = 'JS linter found errors.'; } if (error.plugin === 'gulp-sass') { + notifyTitle = 'CSS'; + notifyMessage = error.relativePath + '\n' + error.line + ' : ' + error.column; + report.push(color.red('Plugin: ') + error.plugin + '\n'); report.push(color.red('File: ') + error.relativePath + '\n'); report.push(color.red('Line: ') + error.line + '\n'); report.push(color.red('Column: ') + error.column + '\n'); report.push(color.red('Note: ') + error.messageOriginal + '\n'); - - notifyMessage = error.relativePath + '\n' + error.line + ' : ' + error.column; } if (error.plugin == 'gulp-stylelint') { - notifyMessage = 'CSS linter found errors.'; + notifyTitle = 'Lint CSS'; + notifyMessage = 'See the console.'; } if (error.plugin === 'gulp-uglify') { + notifyTitle = 'JS'; + notifyMessage = error.cause.filename + '\n' + error.cause.line + ' : ' + error.cause.col; + report.push(color.red('Plugin: ') + error.plugin + '\n'); report.push(color.red('Path: ') + error.fileName + '\n'); report.push(color.red('File: ') + error.cause.filename + '\n'); report.push(color.red('Line: ') + error.cause.line + '\n'); report.push(color.red('Column: ') + error.cause.col + '\n'); report.push(color.red('Note: ') + error.cause.message + '\n'); - - notifyMessage = error.cause.filename + '\n' + error.cause.line + ' : ' + error.cause.col; } // ---------------------------------------------- // Show Mac/Windows notification notify({ - title: 'Failed Gulp — See Console', message: notifyMessage, - sound: 'Sosumi' // Sound for Mac. See: https://github.com/mikaelbr/node-notifier#all-notification-options-with-their-defaults + sound: 'Sosumi', // Sound for Mac. See: https://github.com/mikaelbr/node-notifier#all-notification-options-with-their-defaults + title: 'Gulp Error — ' + notifyTitle }).write(error); beeper(); // Fallback to system sound (for Windows).