grunt-contrib-watch icon indicating copy to clipboard operation
grunt-contrib-watch copied to clipboard

Directory deletions don't trigger a watch event

Open leepowelldev opened this issue 11 years ago • 11 comments

Watch events don't seem to be getting triggered when a directory is deleted.

leepowelldev avatar Jan 09 '14 19:01 leepowelldev

Mind posting your gruntfile, node.js version and operating system?

shama avatar Jan 09 '14 20:01 shama

Sorry, yeah, I'll put together a test case tomorrow.

leepowelldev avatar Jan 09 '14 20:01 leepowelldev

Same here. When I delete a folder, the trigger is not fired

OS: Win8 Node: v0.10.25

Gruntfile:

    watch:
      options:
        livereload: true
        spawn: false
      coffee:
        files: ['src/coffee/**/*.coffee']
        tasks: ['coffee']
      less:
        files: ['src/style/**/*.less']
        tasks: ['less']
      ngtemplates:
        files: ['src/views/**/*.html']
        tasks: ['ngtemplates']
      main:
        files: ['src/i18n/**/*.json', 'src/index.html']
        tasks: ['copy']

amoreira avatar Feb 07 '14 18:02 amoreira

Had the same behavior, seems fixed in the latest version of node (I was about to report this bug but then I noticed the version number of node and upgraded). Fixed in the current version. OSX: 10.9.2 Node: v0.10.26 Grunt: grunt-cli v0.1.13

mrnocreativity avatar Apr 22 '14 20:04 mrnocreativity

Are the patterns matching a folder being deleted? For instance the pattern src/coffee/**/*.coffee would only match a folder named myfolder.coffee/, right?

shama avatar Apr 22 '14 21:04 shama

Just did a quick test because i found that an interesting question. That works also (added a folder test.js and added a file, then removed the folder at once). The watch fired ever step of the way: once upon folder creation, once upon adding the file, once upon deletion :)

mrnocreativity avatar Apr 22 '14 21:04 mrnocreativity

I'm afraid I'll have to retract my statement from earlier on... It seems that on my other machine (same version configs, same gruntfile etc), the folder deletion does not fire when performing the same actions... I'm not sure what's different.

mrnocreativity avatar Apr 22 '14 22:04 mrnocreativity

I also experience this. I would expect a folder deletion to fire off the watch task if its matched by the pattern. It does pick up the event when creating a folder, a file in that folder, or deleting a file in that folder.

This is on: Node 0.10.26 Grunt 0.4.4 Grunt watch 0.6.1

Watch config:

watch: {
      gruntfile: {
        files: ['Gruntfile.js']
      },
      js: {
        options: {
          livereload: true
        },
        files: ['scripts/**'],
        tasks: ['newer:jshint', 'concat:scripts', 'copy:scripts', 'webdav_sync:scripts']
      },
      fonts: {
        files: ['styles/fonts/**'],
        tasks: ['copy:fonts']
      },
      images: {
        files: ['images/**/*.{png,jpg,gif,svg}'],
        tasks: ['newer:imagemin', 'newer:svgmin', 'webdav_sync:images']
      },
      styles: {
        files: ['styles/css/**'],
        tasks: ['concat:styles', 'copy:styles', 'webdav_sync:styles']
      },
      templates: {
        files: ['templates/**'],
        tasks: ['webdav_sync:templates']
      }
    }

ghost avatar May 02 '14 22:05 ghost

Same problem here. Directory deletion does not fire up any event, however something is happening because after deleting the directory AND THEN deleting some other, random FILE Grunt produces an error:

>> watch ENOENT
>> watch ENOENT

(repetition amount is random).

  • node 0.10.30
  • grunt 0.4.5
  • grunt-contrib-watch: 0.6.1

I'm using watch plugin by triggering my custom function bound to the watch event:

grunt.event.on('watch', function (action, filepath, target) {...}

roomcays avatar Jan 10 '15 18:01 roomcays

Still experiencing this issue in:

node v4.5.0 Grunt v1.0.1 grunt-contrib-watch v1.0.0 Ubuntu 14.04.5 LTS

My watch task file pattern is: src/assets/img/**/*

Deleting src/assets/img/dir/file.jpg fires a watch event. Deleting src/assets/img/dir does NOT fire a watch event.

#217 is related, I believe.

andyexeter avatar Sep 12 '16 16:09 andyexeter

This issue still persists.

grunt.event.on('watch', function(action, filepath, target) {
  grunt.log.writeln(target + ': ' + filepath + ' has ' + action);
});

Code above will only log files/directories added, file changes, deletion of files, but not deletion of directories.

  • Grunt 1.0.1
  • Watch 1.0.0
  • Node 7.5.0
  • macOS 10.12.1

audunolsen avatar Feb 17 '17 09:02 audunolsen