Skip to content

Cascading Tasks

Compare
Choose a tag to compare
released this 05 Jul 22:04
· 1038 commits to master since this release
  • Important: Default tasks named as main will be deprecated in 0.2.0. Please update your code accordingly. (This "feature" was originally introduced in v0.1.0)

Cascading Tasks

Inpired by Koa.js cascading middleware.

  • Now it's possible to return a value from a task and receive it in the task executing right after. This opens the door to other ways for tasks to interact with each other.

This change is possible without breaking the API and easily by making Fly.prototype.start([tasks]) return a promise. Up until now start was used in by the CLI engine in /index.js and by Fly.prototype.watch() to run tasks without checking on the return value.

This change also fixes a bug that was causing the reporter to incorrectly display the default task as finished before time sometimes.

Basically it works as follows:

export function* first () {
  return { secret: 42 }
}

export function* second ({ secret }) {
  this.log(`The secret is ${secret}`)
}

export default function* () {
  yield this.start(["first", "second"])
}

See examples/Flyfile-Start.babel.js.

  • Code refactoring and comments improvement in fly.js, index.js, util.js
    • The co-routine used in the CLI is no longer required in bin/index.js and this it is now encapsulated in index.js
  • Now util just exports console.log.bind(console) and console.error.bind(console), this may change in the future if Fly needs to provide a different low level logging mechanism.
  • Updated documentation in English and 日本語.
  • Earl Gray's dependencies were removed. Please npm i earlgrey earlgrey-runtime if you are writing Flyfiles in Earl Gray.