1.1.0 • Published 3 years ago

@denwa/do v1.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

@denwa/do

Javascript based task runner. build and run tasks with javascript in the same spirit as Jake, Grunt.

Use when package.json scripts becomes too scary.

GitHub Workflow Status npm (scoped)

Installation

npm install @denwa/do

Usage

create a do.js file in project repo root.

// import functions
let { sh, task, execute } = require('@denwa/do');

// register hello task
task('hello', () => {
	sh('echo hello friend!');
});

// parse arguments and execute tasks
execute();

execute hello task with following command

$ node do hello
hello friend!

API

sh

execute a shell command, works the same as child_process.execSync except that it catches an exit code of 130 and exits the current process.

function sh(command: string | string[], options: ExecSyncOptions): void

task

register a task callback to be executed, the callback can be sync or async and takes a minimist ParsedArgs object

function task(name: string, callback: (args?: ParsedArgs) => void | Promise<void>): void

execute

executes the tasks register by parsing the command line arguments and invoking the requested task names

async function execute(args?: string[]): Promise<number>

Command Line

node <script> <tasks> <options?>

where

ParameterDescription
scriptname of script file to execute, see do.js example in Usage
tasksone of more space separate task names to execute
optionstask specific options