forked from hyperledger-labs/blockchain-explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.sh
executable file
·80 lines (70 loc) · 1.37 KB
/
main.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
80
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
set -e
# Print usage
function print_help() {
echo "Usage: "
echo " main.sh <mode> [-v]"
echo " <mode> - one of 'install', 'test' or 'clean'"
echo " - 'install' - install all dependencies of the project"
echo " - 'test' - run unit tests of the application and client code"
echo " - 'clean' - clean the project directory of installed dependencies"
echo " -v - enable verbose output"
echo " -h - print this message"
}
function do_install() {
VERBOSE=${VERBOSE:+-ddd}
npm install $VERBOSE
(cd app/test && npm install $VERBOSE)
(cd client && npm install $VERBOSE && npm run build)
}
function do_test() {
(cd app/test && npm run test)
(cd client && npm run test:ci -- -u --coverage)
}
function do_clean() {
rm -rf node_modules
rm -rf client/node_modules client/build client/coverage
rm -rf app/test/node_modules
}
# Get subcommand
SUBCOMMAND=$1
shift
case $SUBCOMMAND in
install | test | clean)
;;
*)
print_help
exit 1
;;
esac
OPTIONS="hv"
VERBOSE=
while getopts "$OPTIONS" opt; do
case "$opt" in
v) VERBOSE=true ;;
h)
print_help
exit 1
;;
*)
echo "Unrecognized option: $opt"
exit 2
;;
esac
done
case $SUBCOMMAND in
install)
do_install
;;
test)
do_test
;;
clean)
do_clean
;;
*)
echo "Logic Error"
exit 3
;;
esac