node package manager
Love JavaScript? Your insights can make it even better. Take the 2017 JavaScript Ecosystem Survey »



NPM version Downloads Build Status Coverage Status

A no-frills task runner. Built on promises to work wonderfully with async and await in Node.js 8 and above. Part of the Ygor toolkit.

Node is the CLI, npm is the plugin system. Go nuts.


$ npm install --save-dev @ygor/tasks


Node is the CLI.

Usage: node <file> [task] [options]
  file   The filename of your script.
  task   The name of the task to run (default: 'default').
  -q, --quiet   Suppress logging (default: false).
      --run     Auto-run task (default: true).

Create a JavaScript file, write some functions, tell Ygor.

// make.js
const tasks = require('@ygor/tasks');
async function bundle() {
    // bundle something
async function instrument() {
    // instrument tests
async function test() {
    // test something
async function cover() {
    await instrument();
    await test();
    // report coverage
    .add('default', bundle)
    .add('test', test);
    .add('cover', cover);

To run a task, execute the file with Node.js (or with babel-node if that's how you roll) and indicate which task to perform.

$ node make
$ node make test
$ node make cover

Deferred Tasks

If you need to define tasks asynchronously, you may call tasks as a function at a later time.

    .then(tools => {
        return tasks()


You may also call tasks() within a task callback to create subtasks.

function childA1() { console.log('hi from a1'); }
function childA2() { console.log('hi from a2'); }
function parentA() {
    // Subtasks
    return tasks()
        .add('1', childA1)
        .add('2', childA2);
function childB1() { console.log('hi from b1'); }
function childB2() { console.log('hi from b2'); }
function parentB() {
    // Subtasks
    return tasks()
        .add('1', childB1)
        .add('2', childB2);
    .add('a', parentA)
    .add('b', parentB);

Then execute subtasks by passing the parent task name as the first argument and the child task name as the second.

$ node make a 2
hi from a2
$ node make b 1
hi from b1

Bring Your Own Arguments

You can override the default cli parsing by providing your own arguments object.

function logCli(cli) {
tasks({ foo: 'bar' })
    .add('log', logCli);
$ node make log
{ foo: 'bar' }



Command-line arguments as parsed by minimist.

tasks.add(name, callback): tasks

  • name {String} Unique task identifier.
  • callback {Function(cli, tasks)} Function to run when the task is invoked.

Registers a task with Ygor. The callback provided will be executed with tasks.cli as the first argument and tasks as the second.

function foo(cli, tasks) {
    console.log(cli, tasks);
tasks.add('foo', foo); Promise<>

  • name {String} Unique task identifier.

Tells Ygor to run a task. This is used internally and generally shouldn't be invoked directly. Ygor recommends that tasks be declared as standalone functions.

// Avoid
tasks.add('foo', function () {
    // do something
tasks.add('bar', function (cli, t) {'foo');
// Recommended
function foo() {
    // do something
function bar() {
    .add('foo', foo)
    .add('bar', bar);

tasks([cli]): tasks

  • options {Object} - The cli arguments. (default: minimist(process.argv.slice(2)))

Creates a subset of tasks, useful for providing your own cli arguments, lazy task definition, and creating subtasks.

© 2017 Shannon Moeller (

Licensed under MIT