forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwatch.sh
executable file
·50 lines (38 loc) · 843 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
source "./utils.sh"
cd ../testrepo
bold "Test: It should watch"
if rewatch clean &> /dev/null;
then
success "Repo Cleaned"
else
error "Error Cleaning Repo"
exit 1
fi
exit_watcher() {
# we need to kill the parent process (rewatch)
kill $(pgrep -P $!);
}
rewatch watch &>/dev/null &
success "Watcher Started"
echo 'Js.log("added-by-test")' >> ./packages/main/src/Main.res
sleep 1
if node ./packages/main/src/Main.mjs | grep 'added-by-test' &> /dev/null;
then
success "Output is correct"
else
error "Output is incorrect"
exit_watcher
exit 1
fi
sleep 1
replace '/Js.log("added-by-test")/d' ./packages/main/src/Main.res;
sleep 1
if git diff --exit-code ./
then
success "Adding and removing changes nothing"
else
error "Adding and removing changes left some artifacts"
exit_watcher
exit 1
fi
exit_watcher