Node module to run a graph of tasks
Node module to run a graph of tasks. This makes it super easy to manage groups of tasks that have dependencies, while running everything asynchronously and in parallel.
var taskGroup = require'task-group';taskGrouptask'dir'fsmkdir'my-dir' done;// The `file` task must have the `dir` task completed before it runstask'file' 'dir'fswriteFile'my-dir/file' 'Test file' done;// Runs the `file` task, which depends on the `dir` taskrun'file'// `err` contains the error if an error occurred in any of the tasks that// were run.// Runs all tasksrun// Run multiple tasksrun'file';
This returns a new task group, which has the
#run methods. The
module exports this function directly.
The returned object's methods can be chained for more concise code.
This method registers a task with the specified name. The name must be a
string. Dependencies can be specified as an array containing the names of tasks
that must be run before this task. If
dependencies is omitted, it is assumed
that there are not dependencies.
action is a function that will be called
when the task is to be run. It will be provided a callback function that it
must call when the task is complete, optionally passing an error to it.
Runs the specified tasks.
tasks can be a single string or an array of strings
specifying all the tasks to run. If
null or omitted, it will run
all the registered tasks.
callback is a function that is called when all
tasks are complete, with the first parameter being the error if an error
MIT License. See the