typo fix and format update
[webi-installers/.git] / watchexec / README.md
1 ---
2 title: watchexec
3 homepage: https://github.com/watchexec/watchexec
4 tagline: |
5   watchexec is a simple, standalone tool that watches a path and runs a command whenever it detects modifications.
6 ---
7
8 ### Updating `watchexec`
9
10 `webi watchexec@stable`
11
12 Use the `@beta` tag for pre-releases.
13
14 ## Cheat Sheet
15
16 `watchexec` runs a given command when any files in watched directories change. \
17 It respects `.[git]ignore`.
18
19 The full `--help` detailed and very useful. Here's the shortlist of what I find
20 most useful:
21
22 ```txt
23 -w, --watch     ./src/      watch the given directory
24 -e, --exts      js,css      watch only the given extensions
25 -i, --ignore    '*.md'      do not watch the given pattern
26 -d, --debounce  5000        the minimum number of milleseconds
27                                 to wait between changes
28
29 -r, --restart               restart the process (for servers, etc)
30 -s, --signal    SIGHUP      like -r, but with a signal (ex: SIGHUP)
31 -c, --clear                 clear the screen between command runs
32 -W  (wait)                  ignore all changes as the command runs
33
34 --              npm start   what command to run, with its arguments
35
36 --no-ignore                 disregard both .ignore and .gitignore
37 --no-vcs-ignore             disregard only .gitignore
38 --no-default-ignore         disregard built-in ignore lists
39 ```
40
41 ### How to use
42
43 Example: List the directory when any files change.
44
45 ```bash
46 watchexec -c -- ls -lah
47 ```
48
49 ### Advanced Usage Example
50
51 Here's a "kitchen sink" example.
52
53 ```bash
54 watchexec -c -r -s SIGKILL -d 2000 -W --verbose \
55     -w ./src -w ./lib -w ./server.js \
56     -e ts,js,sass,css,html \
57     -i '.git' '*.min.js' -i '*.min.css' \
58     -- npm run build
59 ```
60
61 ### How to use (Node, Go, Rust, rsync)
62
63 These examples show how you might use this for builds, servers, and publishing
64 or deploying.
65
66 ```bash
67 # Node / npm
68 watchexec -W -- npm run build
69 watchexec -r -- npm start
70
71 # Golang
72 watchexec -- go build .
73 watchexec -r -- go run .
74
75 # Rust
76 watchexec -- cargo build --bin
77 watchexec -r -- cargo run --bin
78
79 # rsync (local copy)
80 watchexec -- rsync -avhP ./ ./srv/MY_PROJECT/
81
82 # rsync (remote publish)
83 watchexec -- rsync -avhP ./ app@example.com:~/srv/MY_PROJECT/
84 ```