A simple task runner

Usage no npm install needed!

<script type="module">
  import coderesqueTaskRunner from 'https://cdn.skypack.dev/@coderesque/task-runner';



A simple task runner


yarn add --exact @coderesque/task-runner


Define a task.

export default function customTask() {
    return async function run(name: string; context: TaskContext) {
        // Do something.

Add the task to a task runner.

import TaskRunner from '@coderesque/task-runner';
import customTask from './customTask';

const runner = new TaskRunner('build-scripts');
runner.add('custom-task', customTask());

runner.addSequence('custom-sequence', [
], {
    silent: true,




A TaskContext is passed to every task. The context has the following properties:

    silent: boolean;
    run(bin: string, args: string[]): Promise<number>;

silent: boolean

A flag to determine if the task should be run in silent mode. It is the responsibility of the task to define what this means.

type TaskHandler = run(bin: string, args: string[]) => Promise<number>

Run a specific executable with the specified arguments. The exit code of the executable is the return value of this function.


Any task is a function with the following signature.

(name: string, context: TaskContext) => Promise<number>


The TaskRunner is used for coordinating the task execution.

constructor(scriptName: string)

The scriptName is the name that will be displayed together with command name when running a command (task).

commands(): string[]

A list of the names of all the tasks that have been added to the task runner.

add(name: string, handler: TaskHandler): void

Add a task to the task runner.

addSequence(name: string, sequence: string[], context?: Partial<TaskContext>): void

Add a sequence of tasks to the task runner.

start(name: string): void

Start a specific command (task).


This library is being published with our use cases in mind and is not necessarily meant to be consumed by the broader public. We probably won't take your feature requests unless they align with our own needs.