gulp-community / gulp-coffee

Coffeescript plugin for gulp
MIT License
226 stars 70 forks source link

gulp-coffee won't compile after an error occured(and handled) when used with gulp-watch #68

Closed Foolyou closed 9 years ago

Foolyou commented 9 years ago

My gulpfile:

var gulp = require('gulp');
var gutil = require('gulp-util');
var watch = require('gulp-watch');
var coffee = require('gulp-coffee');
gulp.task('watch', function () {
  var src = ...;
  var dest = ...;
  return gulp.src(src)
               .pipe(watch(src).on(change, gutil.log))
               .pipe(coffee().on('error', gutil.log))
               .pipe(gulp.dest(dest));
});

I used gulp watch, and wrote a coffee file which was then compiled. Then I made a syntax error in that coffee file, so gulp logged an error. Gulp still logged file changes when I fixed that syntax error & saved, however coffee file was not compiled again.

yocontra commented 9 years ago

Are you using gulp 4? The watcher is redone, you should try that

Foolyou commented 9 years ago

Thanks @contra.

Do you mean with gulp 4 which uses chokidar, we do not need gulp-watch any more?

I'm considering temporarily use gulp-changed with gulp-watch to avoid this issue, and test gulp 4 with my huge old gulpfile.

Foolyou commented 9 years ago

Ah, found the way.

gulp.task('coffee', function (done) {
  var src = ...;
  var dest = ...;
  return gulp.src(src)
               .pipe(changed(dest))
               .pipe(coffee().on('error', function (p) {
                 gutil.log(p);
                 done(); 
               }))
               .pipe(gulp.dest(dest));
});
gulp.task('watch', function (done) {
  var src = ...;
  var dest = ...;
  return gulp.src(src)
               .pipe(watch(src).on(change, function () { gulp.start('coffee'); }))
});
BirgitPohl commented 8 years ago

@contra I stepped over this issue. With my file watcher I need to restart my gulp task. Can you tell me more about the watcher in Gulp 4? I'm currently using 3.9.1.