B
B
bormor2018-04-17 08:17:01
Node.js
bormor, 2018-04-17 08:17:01

gulp-notify fails in gulp-plumber. What could be wrong?

Handling errors in SCSS using gulp-plumber. Gulp-plumber works (gulp doesn't crash on errors), but it fails to print notifications to the console.
Current code:

const gulp   = require('gulp');
sourcemaps   = require('gulp-sourcemaps');
notify       = require("gulp-notify");
plumber      = require("gulp-plumber");
sass         = require('gulp-sass');


const onError = function (err) {
    notify({
         title: 'Gulp Task Error',
         message: 'Check the console.'
     }).write(err);
     console.log(err.toString());
     this.emit('end');
};


gulp.task('css', () => {

    gulp.src( config.src.cssEntry )
        .pipe(plumber({ errorHandle: onError }) )
        .pipe(sourcemaps.init() )
        .pipe(sass({outputStyle: 'expanded'} )
        .on('error', onError))

What could be wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Balya, 2018-10-17
@Balya

I can share a working solution.

.pipe(plumber({
      errorHandler: function(err) {
        notify.onError({
          title: "Ошибка в CSS",
          message: "<%= error.message %>"
        })(err);
      }
    }))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question