0.20.0 • Published 3 months ago

@rondymesquita/tasks v0.20.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

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
0.20.0

3 months ago

0.19.0

8 months ago

0.15.0

8 months ago

0.16.0

8 months ago

0.17.0

8 months ago

0.18.0

8 months ago

0.14.0

11 months ago

0.13.0

11 months ago

0.12.0

11 months ago

0.11.0

11 months ago

0.10.0

11 months ago

0.9.0

11 months ago

0.8.0

11 months ago

0.7.0

11 months ago

0.6.0

11 months ago

0.5.0

11 months ago

0.4.0

12 months ago