gruntjs / grunt-contrib-watch

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

Modified binary data does not trigger task #216

Open olafgleba opened 11 years ago

olafgleba commented 11 years ago

The copy watch task runs whenever there are changes within a dedicated folder and trigger the folder content to be copied to another location (s. code: copy:imagesSourceToApp).

watch: {
  ...
  copy: {
    files: '<%= project.src %>/img/**/*.{png,jpg,jpeg,gif,svg}',
    tasks: ['copy:imagesSourceToApp']
  }
  ...
}

As long as i add/remove new files, everything is fine.

But if i modify and save a image thats already exists within this folder, the related task is not triggered.

Is this a standard restriction as watch does only look out for changing filenames/folder status or is this a bug? I am not sure...

Thanks for enlighten me ;-)

shama commented 11 years ago

Hmm strange. I have not noticed a difference but I'll look into it.

olafgleba commented 11 years ago

Thanks in advance.

Some additional infos. options.event are not set (implicit 'all'). Tried it with setting them explicitly (['changed', 'added', 'deleted']). No luck. No other options are set for the copy watch task.

dmitrykuznetsovdev commented 10 years ago

does not work grunt.event.on('watch', func) or

allJs: {
        files: '<%=yeoman.main_js %>/**/*.js',
        tasks: ['concat'],
        options: {
          spawn: false
        }
      }

or

allJs: {
        files: '<%=yeoman.main_js %>/**/*.js',
        tasks: ['concat'],
        options: {
          spawn: false,
          event: ['changed', 'added', 'deleted']
        }
      },

works if I define in watch.js event

// On changed/added/deleted
this.on('all', function(status, filepath) {

     grunt.event.emit('test:event:grunt', status, filepath);

     filepath = path.relative(process.cwd(), filepath);
     changedFiles[filepath] = status;
     runTasks(i, target.tasks, options);
 });

also works

fs.watch('somedir', function (event, filename) {
  console.log('event is: ' + event);
  if (filename) {
    console.log('filename provided: ' + filename);
  } else {
    console.log('filename not provided');
  }
});