A
A
Alexey ZloDeeV2014-12-16 17:33:06
JavaScript
Alexey ZloDeeV, 2014-12-16 17:33:06

Why does Gulp-watch's error listener fire on ruby-haml only the first time?

There is the following code in gulpfile.js:

//Function for error log
function log(error) {
  console.log([
    '',
    "===== ERROR MESSAGE START =====".bold.red,
    ('[' + error.name + ' in ' + error.plugin + ']').bold.green,
    error.message,
    "===== ERROR MESSAGE END =======".bold.red,
    ''
    ].join('\n'));
  this.end();
}

...

gulp.task('watch', function() {
  // .. Layouts
  gulp.src([path.layouts.all, path.layouts.views.none])
    .pipe(plugin.watch([path.layouts.all, path.layouts.views.none]))
    .pipe(plugin.rubyHaml()).on('error', log) //error log here
    .pipe(gulp.dest(path.build));
});

...

This code works i.e. if an error occurs in any .haml file, then gulp-watch does not crash, but displays an error message in the console and continues to listen for changes in files. But he does it only for the first time, if you make a mistake in another file or resave this file without correcting anything, the console will happily blink with the inscription "blabla.haml was changed" and, of course, will not compile this file.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Appp Zooo, 2014-12-16
@ikeagold

Move rubyHaml to sub-task it shouldn't be next to .watch, and neither should .dest.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question