Closed Reinmar closed 7 years ago
You are overthinking this. It is not recommended to call the method returned by taker.series
directly, the wrapping libraries take care of that for you.
You shouldn't be wrapping taker.task
or taker.series
in a promise.
If you need to register custom tasks, use a Custom Registry.
If you are just using custom functions for taker.series
, you can just pass it functions directly to the method; you don't have to register them as tasks first.
You most definitely should not be listening to the events emitted by undertaker. They are undocumented and likely to change. They are an implementation detail that leaked to wire up gulp-cli and task resolution.
Thanks for clarifying this.
I must say I'm a bit surprised. I thought that Undertaker will be a great tool to do a gulp-like task management, but outside of gulp.
I'm writing a library which is meant to expose some tasks, but which also should be reusable and easy to use. Hence, it exposes low level tasks (e.g. compileFoo()
, compileBar()
) and some higher level ones (e.g. compileAll()
which internally will call the compileFoo()
and compileBar()
ones). However, I can't use gulp for that because:
gulp -T
),So, for me tasks like compileFoo()
are just functions which can return stream, promise or nothing. In order to implement compileAll()
I need to sync all of them together and this is where I thought I can use undertaker.
It seemed a perfect solution and now I'm puzzled, cause I don't understand:
And, of course, I'd like to know how to solve my case ;). Unfortunately, as you can see, I found the documentation confusing.
The funny thing is that the way I use it, it solves my problems perfectly. For me, this proves undertaker's value and I'd be super happy if its scope could be extended to also cover use cases like mine.
If you'd like to open another issue about this use case with more in-depth examples, I'd be interested in discussing it further and helping you solve/understand the usage. Your usage sounds interesting and I'm quite intrigued.
@Reinmar are you still interested in opening another issue to discuss your use case further?
Yep, I've just opened https://github.com/gulpjs/undertaker/issues/67.
I've been using Undertaker in the following way:
If any of the tasks throws, then I get some useless stack on the console:
I guess that I should handle the errors in this way:
Am I right? I haven't found this in the documentation.