-
Notifications
You must be signed in to change notification settings - Fork 7
/
watch.sh
executable file
·50 lines (39 loc) · 882 Bytes
/
watch.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/zsh
# compile once to start
WEBPID=0
function doit {
(npm run compile || npm run tsc) && npm run test && \
npm run servedocs &
WEBPID=$!
date
echo "OK $WEBPID"
}
function cleanup {
kill $WEBPID
echo "kill $WEBPID"
echo "cleanup"
}
trap cleanup INT
doit
if [ $WEBPID -ne 0 ]; then
# recompile on file change within 1 seconds, except version.ts
fswatch -o -l 1 --exclude version.ts src package.json tsconfig.json | while read stuff; do
echo $stuff
echo "Restarting..."
kill $WEBPID
sleep 1
doit
echo "OK $WEBPID"
done
fi
# compile once to start
npm run compile || npm run tsc
date
echo "OK"
# recompile on file change within 1 seconds, except version.ts
fswatch -o -l 1 --exclude version.ts --exclude handlebarsimport.ts src | while read stuff; do
echo $stuff
npm run compile && npm run test
date
echo "OK"
done