AGoblinKing / dullard

"I have made this longer than usual because I have not had time to make it shorter." - Blaise Pascal

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dullard

Doing the same task repeatedly is boring. Let the computer do it instead.

Build Status NPM version Dependency Status

Usage

Let the computers do the boring stuff.
Usage: dullard -d <dir>,...,<dirN> <step1> ... <stepN>

Options:
  --help, -?     Show usage
  --dirs, -d     directories to load task files from
  --list, -l     List available tasks
  --loglevel     Chattiness, one of: silly, verbose, info, warn, error, & silent  [default: "info"]
  --quiet, -q    Minimal output
  --silent       No output until something goes awry
  --verbose, -v  Verbose logging

Config

Dullard will look for a file named dullfile.js or dullfile.json in the current directory or any parent directories & merge it with the CLI options (CLI takes precendence). It will merge all found results in the current branch of the directory tree with precedence being: CLI -> Local -> Parent -> ... -> Root.

Example Config

JSON version

{
    "dirs" : [
        "../../../tasks-a"
    ],
    
    "steps" : [
        "fooga"
    ]
}

JS version

/*jshint node:true */

"use strict";

module.exports = {
    "dirs" : [
        "../../tasks-a"
    ],
    
    "steps" : {
        main : [
            "fooga"
        ],
        
        finish : [
            "wooga"
        ],
        
        default : [
            "main",
            "finish"
        ]
    }
};

dirs is an array of directories to load tasks from. steps is one of two options: 1) an array of strings/functions or 2) an object containing named step collections that are each an array of strings/fucntions. Strings should match either the names of files in the task directories stripped of their extension or the name of a step collection.

The config object will be passed as the first argument (config by convention) to tasks.

Tasks

Tasks are simple modules that should export a single function. Each task function gets passed two arguments, a shared config object for state in the task chain & an optional callback for async tasks. The callback takes two possible arguments, an error object and an optional object to replace the shared config object. If the task is synchronous any return value will be considered an error.

// Passing tasks
function exampleTaskSync(config) {
    ...
}

function exampleTaskAsync(config, done) {
    ...

    process.nextTick(done);
}

// Failing tasks
function exampleTaskFailureSync(config) {
    return "Task failed";
}

function exampleTaskFailureAsync(config, done) {
    done("Task Failed");
}

FAQ

Q: What about file watching?

A: Nothing built-in yet, still trying to figure out if I'm comfortable with cluttering up the .dullfile(s) with watcher config stuff. For now check out this gist.

About

"I have made this longer than usual because I have not had time to make it shorter." - Blaise Pascal