forked from sourcegraph/sourcegraph-public-snapshot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchangewatch.sh
More file actions
executable file
·68 lines (60 loc) · 1.82 KB
/
changewatch.sh
File metadata and controls
executable file
·68 lines (60 loc) · 1.82 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
cd "$(dirname "${BASH_SOURCE[0]}")/.." # cd to repo root dir
GO_DIRS="$(./dev/watchdirs.sh) ${WATCH_ADDITIONAL_GO_DIRS}"
dirs_starstar() {
for i; do echo "'$i/**/*.go'"; done
}
dirs_path() {
for i; do echo "-path $i"; done
}
useChokidar() {
echo >&2 "Using chokidar."
# eval so the expansion can produce quoted things, and eval can eat the
# quotes, so it doesn't try to expand wildcards.
eval exec chokidar --silent \
$(dirs_starstar $GO_DIRS) \
cmd/frontend/graphqlbackend/schema.graphql \
"'schema/*.json'" \
"'docker-images/grafana/jsonnet/*.jsonnet'" \
"'observability/*'" \
"'cmd/symbols/**/*'" \
"'cmd/symbols/.ctags.d/*'" \
-c "'./dev/handle-change.sh {path}'"
}
execInotifywrapper() {
echo >&2 "Using inotifywrapper."
set -e
pushd dev/inotifywrapper
go build
popd
exec dev/inotifywrapper/inotifywrapper $(dirs_path $GO_DIRS) \
-match '\.go$' \
-match 'cmd/frontend/graphqlbackend/schema\.graphql' \
-match 'schema/.*.json' \
-match 'docker-images/grafana/jsonnet/*.jsonnet' \
-match 'observability/*' \
-cmd './dev/handle-change.sh'
}
execWatchman() {
echo >&2 "Using watchman."
set -e
pushd dev/watchmanwrapper
go build
popd
exec dev/watchmanwrapper/watchmanwrapper dev/handle-change.sh <<-EOT
["subscribe", ".", "gochangewatch", {
"expression": ["anyof",
["suffix", "go"],
["dirname", "cmd/symbols"],
["dirname", "schema"],
["dirname", "docker-images/grafana/jsonnet"],
["dirname", "observability"],
["name", "cmd/frontend/graphqlbackend/schema.graphql", "wholename"]
],
"fields": ["name"]
}]
EOT
}
[ -x "$(command -v watchman)" ] && execWatchman
[ -x "$(command -v inotifywait)" ] && execInotifywrapper
useChokidar