neat-tasks

1.1.1 • Public • Published

neat-tasks

terminal task list for neat-log

npm travis standard

Install

npm install neat-tasks

Usage

See example.js

var neatTasks = require('neat-tasks')
var neatLog = require('neat-log')
var output = require('neat-log/output')
 
var neatLog = require('neat-log')
var output = require('neat-log/output')
var neatTasks = require('neat-tasks')
 
var tasks = [
  {
    title: 'Count Down from 4',
    task: function (state, bus, done) {
      state.count = 3
      var interval = setInterval(function () {
        if (state.count === 0) {
          state.title = 'Lift Off!'
          clearInterval(interval)
          return done(null)
        }
        state.title = `${state.count} seconds remain`
        state.count--
        bus.emit('render')
      }, 1000)
    }
  }
]
 
var runTasks = neatTasks(tasks)
var neat = neatLog(runTasks.view)
neat.use(runTasks.use)

Tasks

Tasks are run one at a time. They can do anything and print out anything to ther terminal while running. Each tasks must have a title and a task function. Tasks can either pass or fail.

{
  title: 'Task title',
  task: function (state, bus, done) {
    // DO STUFF
    done() // Call done() when done
  },
  skip: function (cb) {
    cb(shouldSkip) // Should we skip this task? 
  },
  view: function (state) {
    // neat-log view
  }
}

Use done([fail]) to complete the task.

  • Pass: tests are considered passing if when calling, done(fail), fail is false.
  • Fail: Anything truthy is considered a failure. If you pass a string, it will print the message.

Use the skip cb([skip]) to skip the task.

  • Skip: Anything truthy is considered a failure. If you pass a string, it will change the title after skipping
  • Run: Pass false to run the test

License

MIT

Package Sidebar

Install

npm i neat-tasks

Weekly Downloads

6

Version

1.1.1

License

MIT

Unpacked Size

10.3 kB

Total Files

10

Last publish

Collaborators

  • jhand