Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directory deletions don't trigger a watch event #273

Open
leepowelldev opened this issue Jan 9, 2014 · 11 comments
Open

Directory deletions don't trigger a watch event #273

leepowelldev opened this issue Jan 9, 2014 · 11 comments

Comments

@leepowelldev
Copy link

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

@shama
Copy link
Member

shama commented Jan 9, 2014

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

@leepowelldev
Copy link
Author

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

@amoreira
Copy link

amoreira commented Feb 7, 2014

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']

@mrnocreativity
Copy link

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

@shama
Copy link
Member

shama commented Apr 22, 2014

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

@mrnocreativity
Copy link

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
Copy link

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.

@ghost
Copy link

ghost commented May 2, 2014

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']
      }
    }

@roomcays
Copy link

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) {...}

@andyexeter
Copy link

andyexeter commented Sep 12, 2016

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.

@audunolsen
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants