1. warun
CLI tool which does Watch and Run.
warun
Package: warun
Created by: mysticatea
Last modified: Tue, 24 May 2022 01:34:01 GMT
Version: 1.0.0
License: MIT
Downloads: 674
Repository: https://github.com/mysticatea/wr

Install

npm install warun
yarn add warun

warun

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

Requirements

  • Node.js 4 or later.

๐Ÿ“– Usage

CLI command

Usage: warun <FILES> [OPTIONS] -- <COMMAND> [COMMAND_ARGS]

    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.

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

Examples:
    $ 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.close()

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

The watcher class.

This class inherits EventEmitter.

Parameters
  • 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.

watcher.requestCommand()

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

watcher.open()

Start to watch files.

watcher.close()

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.

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin