Gulp task 'Copy images' copies ALL image files on the first gulp run. Then, task 'Watch source files' watches the images source folder and imagesWatcher.on('add)
intercepts added files. How I can call 'Copy images' from the 'watcher.on()' callback?
Note that gulp task names in camel case are an unwanted limitation.
I know that gulp.run
was removed in gulp4, however here it could be very handy.
gulp.task('Copy images', () => {
// ...
})
gulp.task('Watch source files', () => {
let imagesWatcher = gulp.watch('src/images/**/*.*');
imagesWatcher.on('add', function(path, stats) {
// How to call 'Copy images'?
});
})