1

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?

4

1 回答 1

3

tl;博士:

使用gulp.on('start', callback),gulp.on('stop', callback)gulp.on('error', callback)


Undertaker继承自EventEmitter库。(你可以在这里找到它的 API 文档)

在 Undertaker 中,是负责发出上述事件的文件。您可以查看它以查看传递给回调函数的内容。

PS:自第 4 版发布以来,Gulp 文档变得有些混乱,我也在为此苦苦挣扎,发现 3 和 4 之间的文档冲突,第 3 版文档没有明确的弃用警告。因此,检查 API 中未记录部分的源代码会很有帮助。

于 2019-03-27T17:02:52.417 回答