I'm using this Gulp Watch sample: https://github.com/floatdrop/gulp-watch/blob/master/docs/readme.md#starting-tasks-on-events.
var gulp = require('gulp');
var watch = require('gulp-watch');
var batch = require('gulp-batch');
gulp.task('build', function () { console.log('Working!'); });
gulp.task('watch', function () {
watch('**/*.js', batch(function () {
gulp.start('build');
}));
});
When I run it on my Windows 8 machine, it only runs the first time I change a file:
C:\test>gulp watch
[08:40:21] Using gulpfile C:\test\gulpfile.js
[08:40:21] Starting 'watch'...
[08:40:21] Finished 'watch' after 2.69 ms
[08:40:31] Starting 'build'...
Working!
[08:40:31] Finished 'build' after 261 µs
Next time nothing happens. Why?
If you read the documentation closely, you see the following phrase:
So, that's basically the deal with
gulp-batch
. To constantly watch it, just remove the batch call:(and add the 'done' callback to
build
to let Gulp know when you're finished).Btw... I'm not sure, but I think
gulp-watch
is meant to not only watch files, but also directly returning a vinyl object. So actually using the built-ingulp.watch
should have the same effect:For me it was adding a "return" to the task:
This problem made me crazy for a weekend. I tried all:
But the (reason for this problem and) the solution was so easy that I felt pathetic after that:
Just update your nodejs installation, mine was 0.12.x! No wonder that this doesn't worked.
After that the watch event works again. Sometimes it goes wrong again, too. But in this cases just save your file a second time and it get recognized. (I think
foundation/gulp watch
checks for changes to fast and while your file get replaced with the new uploaded one)I had the same problem and used the same as ddprrt. The difference was using directory wildcard as apposed to absolute path.
I changed this:
to this: