mirror of
https://github.com/watchexec/watchexec.git
synced 2024-11-13 07:41:11 +01:00
70 lines
2.9 KiB
Markdown
70 lines
2.9 KiB
Markdown
watchexec(1) -- execute commands when watched files change
|
|
==========================================================
|
|
|
|
## SYNOPSIS
|
|
|
|
watchexec [`--watch` | `-w` <path>] [`--exts` | `-e` <extensions>]... [`--filter` | `-f` <pattern>]... [`--ignore` | `-i` <pattern>]... [`--restart` | `-r`] [`--clear` | `-c`] [`--postpone` | `-p`] [`--force-poll` <interval>] [`--debug` | `-d`] [`--no-vcs-ignore`] <command> [<argument>...]
|
|
|
|
## DESCRIPTION
|
|
|
|
Recursively monitors directories for changes, executing the command when a filesystem change (add/modify/delete) is detected. By default, watchexec uses efficient kernel-level mechanisms to watch for changes.
|
|
|
|
At startup, the specified <command> (passing any supplied <argument>s) is run once, and watchexec begins monitoring for changes.
|
|
|
|
## OPTIONS
|
|
|
|
* command:
|
|
Command to run when watched files are modified. This command is also run at startup, unless `--postpone` is specified.
|
|
|
|
* `-w`, `--watch` <path>:
|
|
Specifies the path to watch. This argument can be specified multiple times, with all paths being watched simultaneously. Defaults to current directory.
|
|
|
|
* `-e`, `--exts` <extensions>:
|
|
Comma-separated list of file extensions to filter by. Leading dots are allowed (.rs) are allowed. (This is a shorthand for `-f`).
|
|
|
|
* `-f`, `--filter` <pattern>:
|
|
Ignores modifications from paths that do not match <pattern>. This option can be specified multiple times, where a match on any given pattern causes the path to trigger *COMMAND*.
|
|
|
|
* `-i`, `--ignore` *pattern*:
|
|
Ignores modifications from paths that match <pattern>. This option can be specified multiple times, and a match on any pattern causes the path to be ignored.
|
|
|
|
* `-r`, `--restart`:
|
|
Sends SIGTERM to the child process if it is still running when subsequent file modifications are detected, then waits for the child to exit.
|
|
|
|
* `-c`, `--clear`:
|
|
Clears the screen before executing <command>.
|
|
|
|
* `-p`, `--postpone`:
|
|
Postpone execution of <command> until the first file modification is detected.
|
|
|
|
* `-d`, `--debug`:
|
|
Prints diagnostic messages to STDERR
|
|
|
|
* `--force-poll` <interval>:
|
|
When watching directories, poll for changes every <interval> ms instead of using system-specific notification mechanisms (such as inotify). This is useful when you are monitoring NFS shares.
|
|
|
|
* `--no-vcs-ignore`:
|
|
Skip loading of version control system (VCS) ignore files. By default, watchexec loads .gitignore files in the current directory (or parent directories) and uses them to populate the ignore list.
|
|
|
|
## ENVIRONMENT
|
|
|
|
Processes started by watchexec have the $WATCHEXEC_UPDATED_PATH environment variable set to the path of the first modification observed.
|
|
|
|
## EXAMPLES
|
|
|
|
Rebuild a project when source files change:
|
|
|
|
$ watchexec make
|
|
|
|
Watch all HTML, CSS, and JavaScript files for changes:
|
|
|
|
$ watchexec -e html,css,js make
|
|
|
|
Run tests when source files change, clearing the screen each time:
|
|
|
|
$ watchexec -c make test
|
|
|
|
Launch and restart a node.js server
|
|
|
|
$ watchexec -r node app.js
|
|
|