watchwatch will reload the last processed unison file after a haskell… · JavaDerek/unison@a242094 · GitHub
Skip to content

Commit a242094

Browse files
committed
watchwatch will reload the last processed unison file after a haskell/scala build event...
watchwatch.sh also accepts an initial unison file as a command-line arg, e.g. ./scripts/watchwatch.sh scratch.u
1 parent 1ab300d commit a242094

5 files changed

Lines changed: 62 additions & 43 deletions

File tree

‎parser-typechecker/src/Unison/Codebase/Watch.hs‎

Lines changed: 46 additions & 38 deletions

‎parser-typechecker/unison-parser-typechecker.cabal‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ executable watcher
158158
ghc-options: -Wall -fno-warn-name-shadowing -fno-warn-missing-pattern-synonym-signatures
159159
build-depends:
160160
base,
161+
safe,
161162
unison-parser-typechecker
162163

163164
executable tests

‎parser-typechecker/watcher/Main.hs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
module Main where
22

33
import qualified Unison.Codebase.Watch as W
4+
import System.Environment (getArgs)
5+
import Safe (headMay)
46

57
main :: IO ()
6-
main = W.watcher "." 42441
8+
main = do
9+
args <- getArgs
10+
case args of
11+
[""] -> go Nothing
12+
_ -> go (headMay args)
13+
where go x = W.watcher x "." 42441

‎scripts/execwatch.sh‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ haskell_needs_rebuild=x
33
scala_needs_rebuild=x
44
sources_changed=
55
haskell_pid=
6+
last_unison_source="$1"
67

78
function maybe_build_haskell {
89
if [ -n "$haskell_needs_rebuild" ]; then
@@ -26,7 +27,7 @@ function kill_watcher {
2627
}
2728

2829
function start_watcher {
29-
stack exec watcher &
30+
stack exec watcher "$last_unison_source" &
3031
haskell_pid=$!
3132
echo "Launched haskell watcher as pid $haskell_pid."
3233
}
@@ -48,14 +49,14 @@ go
4849

4950
while IFS= read -r changed; do
5051
# echo "debug: $changed"
51-
case $changed in
52+
case "$changed" in
5253
NoOp)
5354
if [ -n "$sources_changed" ]; then
5455
sources_changed=
5556
go
5657
fi
5758
;;
58-
*.hs)
59+
*.hs|*.cabal)
5960
echo "detected change in $changed"
6061
# hasktags -cx parser-typechecker
6162
haskell_needs_rebuild=x
@@ -66,5 +67,7 @@ while IFS= read -r changed; do
6667
scala_needs_rebuild=x
6768
sources_changed=x
6869
;;
70+
*.u|*.uu)
71+
last_unison_source="$changed"
6972
esac
7073
done

‎scripts/watchwatch.sh‎

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)