- Notifications
You must be signed in to change notification settings - Fork0
🍺 Better Error Reporting for Gulp
License
lordgiotto/gulp-beer
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
gulp-beer: better error reporting.
gulp-beer is a simple error handler function that provides some extra features:
- Interactive System Notification (thanks tonode-notifier)
- Custom Server for Errors (opened on notification click) that display all your errors in a more pleasent and straightforward way.
Interactive System Notification
$ npm install --save-dev gulp-beer
Require gulp-beer in yourgulpfile.js:
vargulpBeer=require('gulp-beer');
than simply pass required function as error handler function wherever you like:
gulp.src('*')// stream error.on('error',gulpBeer)// Plumber.pipe(plumber({errorHandler:gulpBeer}))// Other error listener.pipe(sass().on('error',gulpBeer))
You can also call it manually if an error object must be handled
varcustomFunction(err,result){if(err)gulpBeer(err);}
Since error server prevents the gulp process to finish, it has to be started manually when needed (usually when performing a watching task).
Error Handler function expose the server object, so you can do:
gulpBeer.server.start()// to start the error server
gulpBeer.server.stop()// to stop the error server
A simple usage example:
vargulp=require('gulp');vargulpBeer=require('gulp-beer');varplumber=require('gulp-plumber');varsass=require('gulp-sass');functionbuild(){returngulp.src('./src/css/*.scss').pipe(plumber({errorHandler:gulpBeer})).pipe(sass()).pipe(gulp.dest('./dist/css'));}gulp.task('build',build);gulp.task('watch',function(){gulpBeer.server.start();gulp.watch('./src/css/*.scss',['build']);});
Otherwise, if you prefer start it automatically, take a look at the option server.autostart in the "customize handler" section.
If you like, you can customize the error handler function and the error server.
First of all require the custom module:
vargulpBeerFactory=require('gulp-beer/custom');
This will return a factory for the error handler function, which accepts some options as first parameter.
varerrorHandler=gulpBeerFactory(options);
consoleError
[function] : the function that will be used to print the error in the console.
It receives the error object as first argument, decorated with a custom property:
serverUrl
[string | false]: the link to the custom error server related to this specific error
title
[string] Title of the system notification
sound
[boolean | string] Notification sound as describedhere
icon
[boolean | string] Notification sound as describedhere
server
[object | false] Server configuration object. Iffalse
the server start will be prevented also if started manually.
Server configuration object accepts the following properties:
port
[number] : Port on which the server will listenautostart
[boolean] : If true, the server will be started automaticallysilent
[boolean] : Silents server console output