Socket
Socket
Sign inDemoInstall

gulp-beer

Package Overview
Dependencies
146
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    gulp-beer

Gulp (Be)tter (E)rror (R)eporting


Version published
Weekly downloads
2
Maintainers
1
Created
Weekly downloads
 

Readme

Source

gulp-beer

gulp-beer: better error reporting.

gulp-beer is a simple error handler function that provides some extra features:

  • Interactive System Notification (thanks to node-notifier)
  • Custom Server for Errors (opened on notification click) that display all your errors in a more pleasent and straightforward way.

Interactive System Notification system notification

Custom Server for Errors error server

Installation

$ npm install --save-dev gulp-beer

Usage

Require gulp-beer in your gulpfile.js:

var gulpBeer = 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

var customFunction(err, result) {
  if (err) gulpBeer(err);
}

(!!) Start error server (!!)

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:

var gulp = require('gulp');
var gulpBeer = require('gulp-beer');
var plumber = require('gulp-plumber');
var sass = require('gulp-sass');

function build() {
	return gulp.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.

Customize Handler

If you like, you can customize the error handler function and the error server.

First of all require the custom module:

var gulpBeerFactory = require('gulp-beer/custom');

This will return a factory for the error handler function, which accepts some options as first parameter.

var errorHandler = gulpBeerFactory(options);
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 described here


icon [boolean | string] Notification sound as described here


server [object | false] Server configuration object. If false 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 listen
  • autostart [boolean] : If true, the server will be started automatically
  • silent [boolean] : Silents server console output

Keywords

FAQs

Last updated on 27 Mar 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc