Created
October 29, 2015 14:34
-
-
Save luigimannoni/5372222158be15ad67d4 to your computer and use it in GitHub Desktop.
Gulp nice error Handler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Gulp | |
| var gulp = require('gulp'); | |
| // Gulp plug-ins | |
| var plumber = require('gulp-plumber'), // Error pipe streaming | |
| util = require('gulp-util'), // Extends gulp utilities | |
| notify = require('gulp-notify'); // Toast notifications for MacOS and Windows | |
| // Error reporting function. | |
| var reportError = function (error) { | |
| // Log into console and beep. | |
| util.log(util.colors.red('Error'), error.message); | |
| util.beep(); | |
| // Toast message | |
| notify({ | |
| title: 'Task Failed [' + error.plugin + ']', | |
| message: error.message, | |
| }).write(error); | |
| // Prevent the 'watch' task from stopping | |
| this.emit('end'); | |
| }; | |
| /** | |
| * USAGE: | |
| * | |
| * gulp.src(['./src/js/application/**/**.js']) | |
| * .pipe(plumber({ errorHandler: reportError })) | |
| **/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment