forked from CyC2018/CS-Notes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpen CS-Notes Site.command
More file actions
executable file
·47 lines (37 loc) · 920 Bytes
/
Copy pathOpen CS-Notes Site.command
File metadata and controls
executable file
·47 lines (37 loc) · 920 Bytes
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
#!/bin/zsh
set -u
cd -- "$(dirname "$0")" || exit 1
export CS_NOTES_ROOT="$PWD"
URL="http://localhost:3000/#/"
HEALTH_URL="http://localhost:3000/"
if curl -fsS "$HEALTH_URL" >/dev/null 2>&1; then
echo "CS-Notes already appears to be running."
open "$URL"
exit 0
fi
echo "Starting CS-Notes..."
echo "URL: $URL"
echo
/bin/zsh -lic 'cd "$CS_NOTES_ROOT" && npm run docs:serve' &
server_pid=$!
for _ in {1..60}; do
if curl -fsS "$HEALTH_URL" >/dev/null 2>&1; then
echo
echo "CS-Notes is running at $URL"
echo "Press Ctrl+C in this Terminal window to stop the server."
open "$URL"
wait "$server_pid"
exit $?
fi
if ! kill -0 "$server_pid" >/dev/null 2>&1; then
echo
echo "Docsify exited before the site became available."
wait "$server_pid"
exit $?
fi
sleep 0.5
done
echo
echo "Timed out waiting for Docsify to start."
kill "$server_pid" >/dev/null 2>&1
exit 1