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

Watch for folder deletion

Open serhii-babich opened this issue 11 years ago • 6 comments

Need to watch if folder is removed.

serhii-babich avatar Sep 30 '13 11:09 serhii-babich

Could you explain the issue you are having more?

shama avatar Sep 30 '13 15:09 shama

I have a dev folder and tmp folder. Files from dev are copying to tmp, and deleted if deleted in dev. But I need to have a possibility to remove a whole folder too, with or without content. But for now watcher does not react for folder deletion anyway.

serhii-babich avatar Oct 01 '13 06:10 serhii-babich

Which version of node and watch task are you using? and which OS and version are you on? Could you post your gruntfile as well? Thanks!

shama avatar Oct 19 '13 02:10 shama

I still have this issue a few years along the line, removing a directory does not trigger a watch event.

My settings:

watch: {
  "js": {
    "files": ["static/es6/**"],
    "tasks": ["babel:dist"],
    "options": {
      "interrupt": true,
      "spawn": false
    }
  }
}
  • Grunt v0.4.5
  • Watch v0.6.1
  • Node v0.12.4
  • OS X v10.10.5

NoiSek avatar Nov 05 '15 23:11 NoiSek

I'm also having this issue – specifically, folders that are in the "root" level (relative to the pattern) can be deleted without triggering watch, though sub-folders further down are watched OK.

My settings:

watch: {
  images: {
    files: ['src/img/**'],
    tasks: ['clean:images','copy:images']
  }
}

When "src/img/foo" is deleted, watch doesn't trigger. When "src/img/foo/bar" is deleted, watch triggers correctly.

  • Grunt v0.4.5
  • Watch v0.6.1
  • Node v5.5.0
  • OS v10.11.2

rossb avatar Mar 08 '16 21:03 rossb

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