I'm trying to set up a gulp-watch which triggers a gulp task when some files change. For this purpose I'm using the following code:
gulp.task('watchChanges', function(cb){
console.log("Looking for file changes in " + watchPath+".");
return watch(watchPath, ['FilesChanged']);
});
gulp.task('FilesChanged', function (cb){
FilesChanged();
cb();
})
function FilesChanged()
{
console.log("Files changed:")
}
Whenever the files change I would like it if the 'FilesChanged' task would fire and I'd see the "Files changed:" text in console. This doesn't happen.
When I change my watchChanges task to this:
gulp.task('watchChanges', function(cb){
console.log("Looking for file changes in " + watchPath+".");
return watch(watchPath, FilesChanged);
});
Can anyone explain why the first piece of code does not execute correctly?