gulp: gulp.watch with **/*.js and multiple globs not working on Windows

When watching files with Gulp 4, I have the following watch:

gulp.watch(['app/**/*.js', 'app/components/**/*.html']);

On OS X, it works fine for both JS and HTML files, but on Windows 7, making a file change to a JS file does not get detected.

Changing this to the following fixes the issue:

gulp.watch(['app/**/*']);

Also, watching only JS files also works as intended:

gulp.watch(['app/**/*.js']);

It seems only the combination of both globs breaks something causing JS files not to be watched on windows.

Possibly related to https://github.com/floatdrop/gulp-watch/issues/194

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 6
  • Comments: 47 (14 by maintainers)

Most upvoted comments

+1, I repro this on Windows 10, x64. Any way I can help?

@puranjayjain sorry, not sure how to debug this, as I don’t have access to windows. And quite frankly, since I only work on Mac myself, this issue doesn’t impact me much so I don’t want to spend too much more time on it.

If this comes back to bite me again some time I might spend some more time analysing it, but for now I wouldn’t know what to do about it.

@contra Have tested with a simple example, just chokidar v1.4.2:

var chokidar = require('chokidar');
chokidar.watch(['app/**/*.js', 'app/components/**/*.html']).on('all', (event, path) => {
  console.log(event, path);
});

Folder structure: ss

Result is that change detection does work with just chokidar, for both HTML and JS files:

ss

So it seems to be a gulp issue (unless gulp uses an older version of chokidar which was bugged)