Dullard
"I have made this longer than usual because I have not had time to make it shorter." - Blaise Pascal
Dullard is a simple NodeJS-powered task runner. It exists because doing the same thing repeatedly is boring. Much better to let the computer do it instead.
Table of Contents
Usage
$ dullard --help
Let the computers do the boring stuff.
Usage
$ dullard <options> <task>, ..., <taskN>
Options
--help Show this help
--dirs, -d Specify directories to load tasks from
--list, -l Show a list of available tasks
--config, -c Output final assembled config for debugging
--silent, -s No output
--verbose, -v Verbose logging
--silly, -y REALLY verbose logging
--log, -g Specify log level, one of silly, verbose, info, warn, error, & silent
Config
Dullard will look for a file named .dullfile
in the current directory or any parent directories & merge it with the CLI options. It will merge all found results in the current branch of the directory tree with precedence being: CLI > Local > Parent > ... > Root
.
Examples
JSON
"dirs" : "../../../tasks-a" "steps" : "fooga"
Javascript
moduleexports = "dirs" : "../../tasks-a" "steps" : main : "fooga" finish : "wooga" default : "main" "finish" ;
Properties
dirs
dirs
is an array of directories to load tasks from. Paths are relative to the .dullfile
.
steps
steps
defines the order of build steps to run. It supports two different formats.
- an array of strings/functions
- an object containing named step collections that are each an array of strings/functions.
Task names are the names of files in the task directories stripped of their extension or the name of a step collection.
includes
includes
is an array of paths to other .dullfile
s that will be included & merged into the existing config. Paths are relative to the .dullfile
.
... "includes" : "../fooga/wooga/.dullfile"
Customizing Config Values
Dullard tries hard to accept whatever & turn it into something useful. To this end the results of parsing the CLI with optimist
are merged into the config object after all the .dullfile
s. This allows you to run builds with environment-specific settings easily, as you can override any settings via CLI args.
For example, given the following .dullfile
and CLI args
"env" : "dev" ...
invoking dullard using the command dullard --env=live
will set the env
value to "live"
instead of "dev"
.
Thanks to optimist
's ability to handle dot-notation for arguments you can also set nested object arguments.
dullard --env=live --cdn.static=http://www.cdn.com
with the same .dullfile
as above gives you a config
object like this
"env" : "dev" "cdn" : "static" : "http://www.cdn.com" ...
Warning
This only works for values that are not one of Dullard's CLI options.
Tasks
Tasks are modules that export a single function. There's no wrapper around fs
, no streams support baked-in, they're a function that can do some stuff. Every task will be passed a shared config
object that represents the state of dullard & the tasks to be run. For async tasks you can also accept a second argument that can be used as a callback function following the normal node-style error-first pattern.
Sync Tasks
// Passing tasks { // ...} { // ... return undefined;} // Failing tasks { throw "Task failed";}
Async tasks
Tasks can do async work in two different ways. Either by accepting a second callback argument, or returning a promise.
// Passing task { ;} { return { // ... ; };} // Failing task { ;} { return { // ... ; };}
Logging in a task
Dullard makes a log
function available to tasks via config.log
, this is a reference to npmlog.log()
and you may use it accordingly. It respects loglevel values passed via the CLI, either via --loglevel=<level>
or the shorthand --verbose
argument.
Install
npm i -g dullard
Develop
git clone git://github.com/tivac/dullard.git
npm i
- Make changes
npm test