boot-tasks

0.1.3 • Public • Published

boot-tasks

Simple nodejs boot tasks manager. Executes a list of tasks, sync or async. That's all.

Usage example in CoffeeScript:

BootTasks = require 'boot-tasks'
 
# Set final callback 
tasks = new BootTasks ->
  console.log " [*] Server %s listening on %s:%d"
    server.nodename
    argv.host
    argv.port
  server.listen argv.portargv.host
 
# Set sync mode 
tasks.sync()
 
# Add a task: redis 
tasks.task ->
  redisClient = redis.createClient config.redis.port
    config.redis.host
    config.redis.params
 
  redisClient.on 'ready'->
    console.log " [ ] redisClient ready"
    tasks.done()
 
# Run tasks 
tasks.do()

Functions

Constructor

BootTasks = require 'boot-tasks'
tasks = new BootTasks(end)

Optional end parameter as a function to call at the end.

.sync() and .async()

Set the execution mode. Default: sync

.on('done', callback) or .ondone(callback)

Function callback to call at the end.

.task(func)

Add a func function as a task.

.done()

Call at the end of every task to continue execution (only sync mode).

.do(context)

Process all the tasks. Optional context parameter for the tasks.

To-Do

  • Dependency management
  • done function as a parameter
  • Emit events
  • Tests

Readme

Keywords

Package Sidebar

Install

npm i boot-tasks

Weekly Downloads

1

Version

0.1.3

License

MIT

Last publish

Collaborators

  • ignlg