watch

Parameters:
Name Type Required Default Hint
paths string false ** Comma-delimited list of file globbing paths to watch relative to the working directory, defaults to **
excludePaths string false Comma-delimited list of file globbing paths to exclude relative to the working directory.
command string true The command to run when the watcher fires
delay number false 500 How may milliseconds to wait before polling for changes, defaults to 500 ms
directory string false Working directory to start watcher in
verbose boolean false false Output details about the files that changed

Command Usage

Watch the files in a directory and run a custom command of your choice

watch *.json "echo 'config file updated!'"
The following environment variables will be available to your command
- watcher_added - A JSON array of relative paths added in the watch directory
- watcher_removed - A JSON array of relative paths removed in the watch directory
- watcher_changed - A JSON array of relative paths changed in the watch directory
set command = "echo 'You added \${item}!'"

watch command="foreach '\${watcher_added}' \${command}" --verbose
Note in the above example, the ${watcher_added} and ${command} env vars in the "inner" command are escaped.
We also set an intermediate env var to hold the command to keep from needing to "double escape" it.
This command will run in the foreground until you stop it. When you are ready to shut down the watcher, press Ctrl+C.