Watchexec 2.0.0
Release notes
This is the first breaking release. Most of it is cleaning up a number of deprecated options, and changing some defaults. The idea, however, is to start a new era of Watchexec releases, where breaking changes are allowed more easily (to give an idea of how breaking-change-averse the project has been: this release was planned in January 2022! and ever-delayed since).
Fear not! The cadence of breaking releases will be at most once or twice a year, and whenever possible a deprecation will precede a break by at least three months. Watchexec will remain a stable part of your workflow, while allowing ourselves some evolution.
- Shell default changes to
$SHELLwhen it is present. (#210)
Use--shell=shto switch back if your$SHELLis something else. - Shell default changes to Powershell on Windows when Watchexec detects it is running in Powershell. (#80)
Use--shell=cmdto switch back to CMD.EXE, or set theSHELLenvironment variable.
A reminder that Windows 7 is not supported, and hasn't been for years. --on-busy-updatedefaults todo-nothingnow (wasqueue).
Events received while a command is running won't trigger a run of the command immediately following this one.-W/--watch-when-idleis removed, as it is now the default.- The default for
--stop-timeoutis now 10 seconds. --debounce,--delay-run,--poll, and--stop-timeoutnow prefer durations with a unit, and warn if given unit-less durations. The default units for these are millisecond for--debounceand--poll, and seconds for--delay-runand--stop-timeout, which is a source of confusion. Unit-less durations will be removed in a future breaking release.--no-shellis removed.
Use--shell=noneinstead. The-nshort option remains as an alias to--shell=none.-k/--killis removed.
Use--signal=KILLinstead.--changes-onlyis removed.
Use--print-eventsinstead.--emit-events-todefaults tonone, and theenvironmentmode is deprecated.--emit-events-tono longer acceptsstdin(deprecated alias forstdio) andjson-stdin(deprecated alias forjson-stdio).--no-ignoreis removed.
Use--no-project-ignoreinstead.--no-environmentis deprecated.--clear=resetwill reset the screen on graceful shutdown. (#797)--no-process-groupis deprecated.- Watchexec no longer warns (nor does anything else) when it sees the deprecated
WATCHEXEC_FILTERERenvironment variable.
Improvements
- New:
--wrap-process=MODElets you choose between using process groups, process sessions, or nothing at all. (#794) - New: the
WATCHEXEC_TMPDIRenvironment variable can be used to customize where Watchexec will write temporary files, if for some reason your$TMPDIRis unwritable. (#814) - Fix: watchexec no longer creates a temporary file at startup. (#814)
- Fix: the screen is no longer cleared on all events, only when starting a new process. (#809)
Experimental new feature
As a treat, this release also features an experimental new option: -j or --filter-prog, which lets you write filter programs.
-j, --filter-prog EXPRESSION
Provide your own custom filter programs in jaq (similar to jq) syntax. Programs are given an event in the same format as described in --emit-events-to and must return a boolean. In addition to the jaq stdlib, watchexec adds some custom filter definitions:
path | file_metareturns file metadata or null if the file does not exist.path | file_sizereturns the size of the file at path, or null if it does not exist.path | file_read(bytes)returns a string with the first n bytes of the file at path. If the file is smaller than n bytes, the whole file is returned. There is no filter to read the whole file at once to encourage limiting the amount of data read and processed.string | hash, andpath | file_hashreturn the hash of the string or file at path. No guarantee is made about the algorithm used: treat it as an opaque value.any | kv_store(key),kv_fetch(key), andkv_clearprovide a simple key-value store. Data is kept in memory only, there is no persistence. Consistency is not guaranteed.any | printout,any | printerr, andany | log(level)will print or log any given value to stdout, stderr, or the log (levels = error, warn, info, debug, trace), and pass the value through (so[1] | log("debug") | .[]will produce a1and log[1]).
All filtering done with such programs, and especially those using kv or filesystem access, is much slower than the other filtering methods. If filtering is too slow, events will back up and stall watchexec. Take care when designing your filters.
If the argument to this option starts with an '@', the rest of the argument is taken to be the path to a file containing a jaq program.
Jaq programs are run in order, after all other filters, and short-circuit: if a filter (jaq or not) rejects an event, execution stops there, and no other filters are run. Additionally, they stop after outputting the first value, so you'll want to use 'any' or 'all' when iterating, otherwise only the first item will be processed, which can be quite confusing!
Examples:
Regexp ignore filter on paths:
all(.tags[] | select(.kind == "path"); .absolute | test("[.]test[.]js$")) | not
Pass any event that creates a file:
any(.tags[] | select(.kind == "fs"); .simple == "create")
Pass events that touch executable files:
any(.tags[] | select(.kind == "path" && .filetype == "file"); .absolute | metadata | .executable)
Ignore files that start with shebangs:
any(.tags[] | select(.kind == "path" && .filetype == "file"); .absolute | read(2) == "#!") | not
More examples can be found and contributed in the discussion thread
Packages
View release on GitHub.
Checksums
| BLAKE3 checksums |
|---|
| SHA256 checksums |
| SHA512 checksums |
version released on 2024-04-20 | this page built on 2026-03-30 at 18:52 | generator v0.0.2 | json metadata