-
Notifications
You must be signed in to change notification settings - Fork 39
/
build.sh
executable file
·79 lines (68 loc) · 1.52 KB
/
build.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bash
SHOW_HELP=0
NPM_WATCH=0
RUN_SERVER=0
RUN_ELECTRON=0
while [ -n "$*" ]; do
case $1 in
-h)
# Show help
SHOW_HELP=1
;;
-w)
# Use "npm run watch" instead of "npm run build", to enable hot swapping
NPM_WATCH=1
;;
-s)
# Run server after building
RUN_SERVER=1
;;
-e)
# Run electron after building
RUN_ELECTRON=1
;;
esac
shift
done
if [ "${SHOW_HELP}" -eq 1 ]; then
echo
echo "Usage:"
echo "build.sh [-h] [-w] [-s] [-e]"
echo
echo "-h: show help"
echo "-w: use 'npm run watch' instead of 'npm run build', to enable hot swapping"
echo "-s: run UI server after completing the build"
echo "-e: run electron server after completing the build"
echo
exit
fi
WATCH_PID=$(cat "watch.pid" || echo "")
if [ ! -z "${WATCH_PID}" ]; then
echo "Stopping existing watch process..."
kill "${WATCH_PID}"
rm -f "watch.pid"
fi
if [ "${NPM_WATCH}" -eq 1 ]; then
echo "Building qortal-ui in watch mode..."
npm run watch &
echo "$!" > "watch.pid";
else
npm run build
fi
if [ "${RUN_SERVER}" -eq 1 ]; then
echo "Running UI server..."
trap : INT
npm run server
elif [ "${RUN_ELECTRON}" -eq 1 ]; then
echo "Starting electron..."
trap : INT
npm run start-electron
fi
WATCH_PID=$(cat "watch.pid" || echo "")
if [ ! -z "${WATCH_PID}" ]; then
echo "Stopping watch process..."
kill "${WATCH_PID}"
rm -f "watch.pid"
fi
# Catch-all to kill any remaining processes
pkill -P $$