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.
npm install @denwa/do
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!
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
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
executes the tasks register by parsing the command line arguments and invoking the requested task names
async function execute(args?: string[]): Promise<number>
node <script> <tasks> <options?>
where
Parameter | Description |
---|---|
script | name of script file to execute, see do.js example in Usage |
tasks | one of more space separate task names to execute |
options | task specific options |