Skip to content

Instantly share code, notes, and snippets.

@joaocunha
Last active August 29, 2015 14:15
Show Gist options
  • Save joaocunha/ecdb5e606be75faac897 to your computer and use it in GitHub Desktop.
Save joaocunha/ecdb5e606be75faac897 to your computer and use it in GitHub Desktop.
Basic error handling capabilities for gulp
var gulp = require('gulp');
var paths = {
src: 'src',
dist: 'dist'
};
// ---------------------------------------
// BASIC ERROR HANDLING
var gutil = require('gulp-util');
var notify = require('gulp-notify');
function handleError(err) {
notify.onError({
title: "Gulp",
subtitle: "Failure!",
message: "Error: <%= error.message %>",
sound: "Beep"
})(err);
err = gutil.colors.red(err);
gutil.log(err);
gutil.beep();
this.emit('end');
}
// ---------------------------------------
// STYLUS
var stylus = require('gulp-stylus');
var rename = require('gulp-rename');
var jeet = require('jeet');
var rupture = require('rupture');
gulp.task('stylus', ['clean:css'], function () {
return gulp.src(paths.src + '/stylus/*.styl')
.pipe(stylus({
use: [jeet(), rupture()],
compress: true,
}))
.on('error', handleError)
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest(paths.dist + '/css'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment