Promise support for API
luvies opened this issue · 8 comments
Would it be possible to provide promise-based versions of the API jake provides to allow a Jakefile to be written completely with async/awaits? Using util.promisify
you should be able to have a small function that loops through the API functions and converts them I would think.
You could alternatively make it so that commands like jake.exec
return a promise if no callback is passed in
Any updates here? This can make jake more modern.
Never mind, I just published a new task runner cli app which support promise: https://github.com/zaaack/foy
I actually did something similar (luvies/take), which is why I've mostly given up on this issue (athough I need to put some more work into it)
They both look... promising :-), but neither of them appears to do a topological sort of the dependencies, which IMO is the most important feature of a make/rake-like task runner.
My task runner does actually build up a full dependency tree, making it perform all dependency-less targets in parallel would be trivial I think (I already support a parallelDeps
option that does this, but only for the dependencies of the current target). I haven't really seen topological sorts before tbh, but it looks like I did at least something like it instinctively. I also implemented this so I could detect things like circular dependencies easily & before execution.
@chocolateboy Well, mine just added a simple hash set for tasks in the dependency tree, each task with same name and options will be identified as a standalone task and will be executed once. Also, each task is executed serialized by default. But you can use options to change them, like force rerun, parallelize dependencies' execution.
Seems like most of the API works async, but invoke
and execute
aren't, making it hard to call other tasks that are async.