shama / gaze

:crystal_ball: A globbing fs.watch wrapper built from the best parts of other fine watch libs.
MIT License
1.15k stars 168 forks source link

Watch is detecting the same file twice on minimal example #243

Open dman777 opened 7 years ago

dman777 commented 7 years ago

Using Windows 7:

$ gulp --version
[14:00:20] CLI version 3.9.1
[14:00:20] Local version 3.9.1

gulp.watch is catching the same file change twice. I used to separate editors(vi and notepad) to make sure it was not the editor saving the file twice. I also tried debounceDelay and interval with on success to rid the the problem:

$ gulp watch
[13:57:27] Using gulpfile C:\git\global-spredfast-world-wall\gulpfile.js
[13:57:27] Starting 'watch'...
[13:57:27] Finished 'watch' after 8.44 ms
{ type: 'changed',
  path: 'C:\\git\\global-spredfast-world-wall\\index.html' }
{ type: 'changed',
  path: 'C:\\git\\global-spredfast-world-wall\\index.html' }
const gulp = require('gulp');
var browserSync = require('browser-sync').create();

gulp.task('serve', ['watch', 'browserSync']);
gulp.task('watch', watch);

function reloadBrowserSync(done) {
  console.log(done)
  browserSync.reload();
}

gulp.task('browserSync', function() {
    browserSync.init({
        server: {
            baseDir: "./"
        }
    });
});

function watch() {
  gulp.watch([
    'index.html'
  ], function(event){ console.log(event)});
}