With Gulp, you can access the path of a fired event by using the watch().on()
method for each event type:
const { watch } = require('gulp');
watch('*.js').on('change', (path, stats) => {
console.log(`File ${path} was changed`);
});
watch('*.js').on('add', (path, stats) => {
console.log(`File ${path} was added`);
});
You can also watch for multiple event types using the events
option, but you don't get access to the path of a fired event:
watch('*.js', { events: ['change', 'add'] }, cb => {
// body omitted
cb();
});
Is there a way to access the path of a fired event from a single anonymous handler when watching for multiple event types?
from Accessing the event path of any fired event of many event types when watching files in Gulp
No comments:
Post a Comment