From e2a38ecb0b28ee2a28666284d29629209516f5b8 Mon Sep 17 00:00:00 2001 From: jawinn Date: Thu, 2 Jul 2015 21:59:56 -0400 Subject: [PATCH] Stop "gulp watch" from crashing on an undefined variable If you're using "gulp watch", and happen to type a variable that's undefined, it will stop with an error about an unhandled error. The fix is to pass gulp-plumber an error callback (Solution found here: https://github.com/yeoman/generator-gulp-webapp/issues/154#issuecomment-45990783). Now instead of stopping, it will provide the error text in red, in the commandline. --- gulpfile.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 17978ff6..b876ffab 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -14,7 +14,10 @@ var gulp = require('gulp'), // Compile Sass, Autoprefix and minify gulp.task('styles', function() { return gulp.src('./assets/scss/**/*.scss') - .pipe(plumber()) + .pipe(plumber(function(error) { + gutil.log(gutil.colors.red(error.message)); + this.emit('end'); + })) .pipe(sass()) .pipe(autoprefixer({ browsers: ['last 2 versions'], @@ -93,4 +96,4 @@ gulp.task('watch', function() { // Watch foundation-js files gulp.watch('./bower_components/foundation/js/foundation/*.js', ['foundation-js']); -}); \ No newline at end of file +});