jakejs / jake

JavaScript build tool, similar to Make or Rake. Built to work with Node.js.
http://jakejs.com
Apache License 2.0
1.97k stars 190 forks source link

Promise support for API #351

Open luvies opened 6 years ago

luvies commented 6 years ago

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.

luvies commented 6 years ago

You could alternatively make it so that commands like jake.exec return a promise if no callback is passed in

zaaack commented 5 years ago

Any updates here? This can make jake more modern.

zaaack commented 5 years ago

Never mind, I just published a new task runner cli app which support promise: https://github.com/zaaack/foy

luvies commented 5 years ago

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)

chocolateboy commented 5 years ago

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.

luvies commented 5 years ago

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.

zaaack commented 5 years ago

@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.

NoahTheDuke commented 4 years ago

Seems like most of the API works async, but invoke and execute aren't, making it hard to call other tasks that are async.