-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwatchman-simple.sh
35 lines (25 loc) · 1006 Bytes
/
watchman-simple.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Example usage: bash watchman-simple.sh node src/videoAPI.js
__watchman-add() {
watchman watch .
watchman watch-list
# clear the log so the last run do not cause confusion
printf '\n%.0s' {1..10} >> /usr/local/var/run/watchman/${USER}-state/log
# '**/*' results in argument list too long, so this must be restarted after updating node_modules
#watchman -- trigger . "$WATCHNAME" '**/*.js' -- $@
# this only seems to work when globbing
#watchman -- trigger . "$WATCHNAME" '**[^node_modules]/*.js' -- $@
# so being super specific
watchman -- trigger . "$WATCHNAME" 'src/*.js' 'src/*/*.js' -- $@
watchman trigger-list .
trap watchman-del EXIT
# Look for a more trigger-specific log
tail -f /usr/local/var/run/watchman/${USER}-state/log
}
watchman-del() {
watchman trigger-del . "$WATCHNAME"
# only remove when all triggers are deleted
# /usr/local/var/run/watchman/${USER}-state/state
#watchman watch-del .
}
WATCHNAME="$(basename "$PWD")"
__watchman-add "$@"