@rondymesquita/tasks
TypeScript icon, indicating that this package has built-in type declarations

0.20.0 • Public • Published

tasks

Simple task runner

async function clean() {
  await new Promise((res) => setTimeout(res, 2000))
}

function build() {
  console.log('building')
}

tasks({
  clean,
  build,
})


$ node tasks.js clean
$ node tasks.js build

Help

$ node tasks.js --help

Task args

function build({ id, minify }) {
  console.log('building', )
}

tasks({
  build,
})


$ node tasks.js build --id=2 --minify=true

Default tasks

Run a default task when no task name is informed.

function build() {}

tasks({
  default: build,
})


$ node tasks.js --id=2

Namespaces

const test = {

  unit: ({ reporter }) => {
    console.log('running unit tests')
  },

  e2e: async () => {
    console.log('runnint e2e tests')
    await new Promise((res) => setTimeout(res, 2000))
  }
}

tasks({
  test,
})


$ node tasks.js test:unit --reporter=awesome-reporter
$ node tasks.js test:e2e

Sequence

Pass array of tasks.

async function clean() {
  await new Promise((res) => setTimeout(res, 2000))
}

function build() {
  console.log('building')
}

tasks({
  build: [clean, build],
})


$ node tasks.js build

Context

Share data between tasks in sequence

function jobid(options, ctx) {
  ctx.set('id', 12345)
}

async function clean(options, ctx) {
  console.log('cleaning', ctx.get('id'))
  await new Promise((res) => setTimeout(res, 2000))
}

function build(options, ctx) {
  console.log('building', ctx.get('id'))
}

tasks({
  build: [jobid, clean, build],
})


$ node tasks.js build

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.20.0
    0
    • latest

Version History

Package Sidebar

Install

npm i @rondymesquita/tasks

Weekly Downloads

2

Version

0.20.0

License

MIT

Unpacked Size

25.9 kB

Total Files

15

Last publish

Collaborators

  • rondymesquita