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

Can A Rule Be An Async Function? #393

Open virtualpatterns opened 3 years ago

virtualpatterns commented 3 years ago

I've tried the following as a test ...

Rule('b', 'source/index.js', function () {
  console.log(`Waiting on '${this.name}' ...`)
  return new Promise((resolve) => {
    setTimeout(resolve, 5000)
  })
})

Task('a', [ 'b' ], function () {
  console.log(`Waiting on '${this.name}' ...`)
  return new Promise((resolve) => {
    setTimeout(resolve, 5000)
  })
})

... but the Rule is never waited upon. The Rule should take at least 5s to run but it takes < 1ms ... it is never completed.

Sync Rule functions behave as expected but not async functions. Should they?