Reputation: 4519
In Gulp 3.x there was the ability to tie into its event system with Orchestrator to do things when a task starts or a task ends by using the task_start
, task_stop
or stop
listeners.
Example:
gulp.on('task_start', (e) => {
// Task event information
console.log(e);
});
It seems Gulp has removed Orchestrator and replaced it with a new library called Undertaker. However, I can't find any reference to an internal API event system now in Gulp.
Is there any way to achieve these type of events in a custom Gulp plugin still in version 4.x?
Upvotes: 2
Views: 151
Reputation: 527
tl;dr:
use gulp.on('start', callback)
, gulp.on('stop', callback)
and gulp.on('error', callback)
Undertaker inherits from EventEmitter library. (you can find its API docs here)
in Undertaker, this is the file responsible for emitting the above cited event. You can check it out to see what's being passed to the callback function.
PS: Since version 4 release, Gulp documentation has become a bit of a mess, I'm struggling with this too, finding conflicting docs between 3 and 4, with no clear deprecation warnings with version 3 docs. So checking the source code for undocumented parts of the API can be of a great help.
Upvotes: 4