CLI tool which does Watch and Run.


311.0.04 years ago4 years agoMinified + gzip package size for warun in KB



npm version Downloads/month Build Status Build Status codecov Dependency Status

Watch files and run a command when they change.

โคด๏ธ Motivation

This is CLI tool similar to chokidar-cli. However, this does not run the command immediately if changes happen while the command is running. In that case, this waits for the finish of the previous command then this runs the command. This will be useful if the command needs a long time.

๐Ÿ’ฟ Installation

Use npm to install.

$ npm install -D warun


  • Node.js 4 or later.

๐Ÿ“– Usage

CLI command


    Watch files and Run a command.

    FILES .......... One or more glob patterns to watch files.
    OPTIONS ........ Options below.
    COMMAND ........ The command name to run.
    COMMAND_ARGS ... The arguments of the command.

    --no-initial .......... The flag to prevent the first run at ready.
    --debounce <number> ... The debounce wait time in milliseconds.

    $ warun lib test -- npm test
    $ warun src --no-initial -- npm run build

Node.js API

const warun = require("warun")

// Start watching
const watcher = warun.watch(["src"], "npm", ["run", "build"])

// Stop watching

watcher = new warun.Watcher(patterns, command, args, options)

The watcher class.
This class inherits EventEmitter.

  • patterns (string | string[]) ... The glob patterns of target files.
  • command (string) ... The command to run.
  • args (string[]) ... The arguments of the command.
  • options (object) ... The options.
    • options.initial (boolean) ... The flag to run the command at ready. Default is true.
    • options.debounce (number) ... The debounce wait time in milliseconds. Default is 250.


Request to run the command. Calls of this method are debounced.


Start to watch files.


Stop watching.

watcher.on("ready", () => {})

The ready event. It emits this event once after the watching of all target files started.

watcher.on("change", (event) => {})

The change event of files. It emits this event on every change of files.

  • event.type is the type of the change.
  • event.path is the path to the changed file.

watcher.on("error", (error) => {})

The error event of files. It emits this event on every error of the watcher.

๐Ÿ“ฐ Changelog

๐Ÿป Contributing

Contributing is welcome โค

Please use GitHub's Issues/PRs.

Development Tools

  • npm test runs tests and measures coverage.
  • npm run coverage shows the coverage result of npm test command.
  • npm run lint runs ESLint.
  • npm run watch runs warun to run tests on every file change.

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.