warun v1.0.0
warun
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 warunRequirements
- 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 buildNode.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 istrue.options.debounce(number) ... The debounce wait time in milliseconds. Default is250.
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.typeis the type of the change.event.pathis 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 testruns tests and measures coverage.npm run coverageshows the coverage result ofnpm testcommand.npm run lintruns ESLint.npm run watchrunswarunto run tests on every file change.
8 years ago