1.3.0 • Public • Published


    A simple cli task runner. When you would prefer to write code rather than shell scripts in package.json, but would rather not spend a lot of time learning a build tool.

    Requires node v4 or newer.


    run-task returns a function that takes an object as an argument. The keys are the names of tasks and the values are functions for those tasks.

    • Write some functions, then pass in the ones you want to be tasks.
    // filename: run.js
    const tasks = require('run-task')
    function foo () {
    function bar () {
    function foobar () {
    • Execute using node [script] [task].
    $ node run foobar
    • If you use JSDoc comments, it will pick up the description. You can also add a description by attaching a description property to the function.
     * This will show up as the task's description on stdout.
    function bar () {
    function bar () {
    bar.description = "This will show up as the task's description on stdout."
    • You can pass in more than one task.
    $ node run bar foobar
    • If you don't provide a task argument, it will list the available tasks.
    $ node run
    [run] Available tasks:
    [run] bar - This will show up as the task's description on stdout.
    [run] foobar
    • You can also pass in a -q flag to silence the run-task logging.
    $ node run bar -q

    That's it. It just runs functions from the command line. There are no assumptions on what kind of tasks you want to run.

    Because of this, you'll probably want to require some other modules in your run.js script.

    • There's a lot you can get done with the core api, read the docs
    • Check out a curated list of modules at awesome-nodejs.
    • shelljs is a great tool for tasks (cross-platform *nix commands for node).

    Other Suggestions

    • Take advantage of the property shorthand.
    • Name the file containing the tasks run.js so you can use: node run [task].


    npm i run-task

    DownloadsWeekly Downloads






    Last publish


    • avatar