Tweaking error handling setup

This commit is contained in:
Jeff Avallone 2015-11-01 07:21:17 -05:00
parent c02fb6406b
commit fb4b39e75b
2 changed files with 4 additions and 12 deletions

View File

@ -1,15 +1,8 @@
var gulp = require('gulp'), var gulp = require('gulp'),
_ = require('lodash'), _ = require('lodash'),
notify = require('gulp-notify'), notify = require('gulp-notify'),
plumber = require('gulp-plumber'),
config = require('./config'); config = require('./config');
function errorHandler() {
return plumber({
errorHandler: notify.onError('Error: <%= error.message %>')
});
}
gulp.task('default', ['server', 'docs'], function() { gulp.task('default', ['server', 'docs'], function() {
gulp.watch(config.globs.other, ['static']); gulp.watch(config.globs.other, ['static']);
gulp.watch(_.flatten([ gulp.watch(_.flatten([
@ -55,7 +48,6 @@ gulp.task('build', ['static', 'markup', 'styles', 'scripts']);
gulp.task('static', function() { gulp.task('static', function() {
return gulp.src(config.globs.other, { base: './src' }) return gulp.src(config.globs.other, { base: './src' })
.pipe(errorHandler())
.pipe(gulp.dest(config.buildRoot)); .pipe(gulp.dest(config.buildRoot));
}); });
@ -65,7 +57,6 @@ gulp.task('markup', ['styles'], function() {
rename = require('gulp-rename'); rename = require('gulp-rename');
return gulp.src(config.globs.templates) return gulp.src(config.globs.templates)
.pipe(errorHandler())
.pipe(frontMatter()) .pipe(frontMatter())
.pipe(hb({ .pipe(hb({
data: config.globs.data, data: config.globs.data,
@ -73,6 +64,7 @@ gulp.task('markup', ['styles'], function() {
partials: config.globs.partials, partials: config.globs.partials,
bustCache: true, bustCache: true,
})) }))
.on('error', notify.onError())
.pipe(rename(function(path) { .pipe(rename(function(path) {
path.extname = '.html'; path.extname = '.html';
})) }))
@ -85,16 +77,16 @@ gulp.task('styles', function() {
rename = require('gulp-rename'); rename = require('gulp-rename');
return gulp.src(config.globs.sass) return gulp.src(config.globs.sass)
.pipe(errorHandler())
.pipe(sourcemaps.init()) .pipe(sourcemaps.init())
.pipe(sass({ .pipe(sass({
includePaths: require('node-bourbon').includePaths includePaths: require('node-bourbon').includePaths
})) }))
.on('error', notify.onError())
.pipe(rename(function(path) { .pipe(rename(function(path) {
path.dirname = ''; path.dirname = '';
})) }))
.pipe(sourcemaps.write('.')) .pipe(sourcemaps.write('.'))
.pipe(gulp.dest(config.buildPath('css'))); .pipe(gulp.dest(config.buildPath('css')))
}); });
gulp.task('scripts', function() { gulp.task('scripts', function() {
@ -110,6 +102,7 @@ gulp.task('scripts', function() {
.add('./src/js/main.js'); .add('./src/js/main.js');
return b.bundle() return b.bundle()
.on('error', notify.onError())
.pipe(source('./src/js/main.js')) .pipe(source('./src/js/main.js'))
.pipe(buffer()) .pipe(buffer())
.pipe(sourcemaps.init({ loadMaps: true })) .pipe(sourcemaps.init({ loadMaps: true }))

View File

@ -21,7 +21,6 @@
"gulp-front-matter": "^1.3.0", "gulp-front-matter": "^1.3.0",
"gulp-hb": "^2.6.5", "gulp-hb": "^2.6.5",
"gulp-notify": "^2.0.1", "gulp-notify": "^2.0.1",
"gulp-plumber": "^1.0.0",
"gulp-rename": "^1.2.2", "gulp-rename": "^1.2.2",
"gulp-sass": "^2.1.0", "gulp-sass": "^2.1.0",
"gulp-sourcemaps": "^1.6.0", "gulp-sourcemaps": "^1.6.0",