Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Maintaining three different ways to watch files leads to unneccessary bugs. Instead lets pick just one.
- Loading branch information
1 parent
c8c3439
commit 5a1c63b
Showing
6 changed files
with
37 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
unset CDPATH | ||
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 | ||
} | ||
# Wrapper for watchman. To debug which changes it detect set the environment | ||
# variable WATCHMAN_DEBUG=t | ||
|
||
dirs_path() { | ||
for i; do echo "-path $i"; done | ||
} | ||
if [ ! -x "$(command -v watchman)" ]; then | ||
echo "Please install watchman. https://facebook.github.io/watchman/docs/install.html" | ||
echo | ||
echo " brew install watchman" | ||
exit 1 | ||
fi | ||
|
||
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. | ||
# shellcheck disable=2046,2086 | ||
eval exec chokidar --silent \ | ||
$(dirs_starstar $GO_DIRS) \ | ||
cmd/frontend/graphqlbackend/schema.graphql \ | ||
"'schema/*.json'" \ | ||
"'docker-images/grafana/jsonnet/*.jsonnet'" \ | ||
"'monitoring/*'" \ | ||
"'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 | ||
# shellcheck disable=2046,2086 | ||
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 'monitoring/*' \ | ||
-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": ["allof", | ||
["not", ["anyof", | ||
["match", ".*"], | ||
["suffix", "_test.go"]]], | ||
["anyof", | ||
["suffix", "go"], | ||
["dirname", "cmd/symbols"], | ||
["dirname", "schema"], | ||
["dirname", "docker-images/grafana/jsonnet"], | ||
["dirname", "monitoring"], | ||
["name", "cmd/frontend/graphqlbackend/schema.graphql", "wholename"]]], | ||
"fields": ["name"] | ||
}] | ||
EOT | ||
} | ||
|
||
[ -x "$(command -v watchman)" ] && execWatchman | ||
[ -x "$(command -v inotifywait)" ] && execInotifywrapper | ||
|
||
useChokidar | ||
exec go run ./dev/watchmanwrapper dev/handle-change.sh <dev/watchmanwrapper/watch.json |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[ | ||
"subscribe", | ||
".", | ||
"gochangewatch", | ||
{ | ||
"expression": [ | ||
"allof", | ||
["not", ["anyof", ["match", ".*"], ["suffix", "_test.go"]]], | ||
[ | ||
"anyof", | ||
["suffix", "go"], | ||
["dirname", "cmd/symbols"], | ||
["dirname", "schema"], | ||
["dirname", "docker-images/grafana/jsonnet"], | ||
["dirname", "monitoring"], | ||
["name", "cmd/frontend/graphqlbackend/schema.graphql", "wholename"] | ||
] | ||
], | ||
"fields": ["name"] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters