gruntjs / grunt-contrib-watch

Run tasks whenever watched files change.
http://gruntjs.com/
MIT License
1.98k stars 356 forks source link

Watch fires when a directory is created in the same directory as a file target #519

Open SCdF opened 7 years ago

SCdF commented 7 years ago

Test case repository: https://github.com/SCdF/grunt-contrib-watch-watches-dirs-by-mistake

Basically, given the following watch config:

watch: {
  shouldFire: {
    files: ['shouldFire', 'shouldFireDir/shouldFire'],
    tasks: ['printstuff']
  }
}

I would expect that only two files could cause the task to fire: the shouldFire file and the second shouldFire file under the shouldFireDir directory.

However, the task is fired if a directory is created in either the repo's root directory, or under the shouldFireDir directory. For example, if I mkdir blah in the root directory, this task fires. Note that this issue only occurs if you create a directory: touching a file does not cause the task to incorrectly fire.

Either this is incorrect or I do not understand how the files matching syntax works.

SCdF commented 7 years ago

Looks like this is caused by Gaze: https://github.com/shama/gaze/issues/204

SCdF commented 7 years ago

Created the following PR to work around Gaze: https://github.com/gruntjs/grunt-contrib-watch/pull/520