forked from RouteInjector/ri-backoffice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommand.sh
executable file
·64 lines (59 loc) · 1.34 KB
/
command.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
#!/usr/bin/env bash
# Output colors
NORMAL='\033[0m' # No Color
RED='\033[0;31m'
BLUE='\033[0;34m'
DIR=`pwd`
# INTERNAL USAGE
log() {
echo -e "${BLUE}${1}${NORMAL}"
}
# INTERNAL USAGE
error() {
echo -e "${RED}ERROR - ${1}${NORMAL}"
return -1
}
check_exit() {
rc=$?; if [[ $rc != 0 ]]; then
error "Something wrong happened. Check logs :(";
exit $rc;
fi
}
install() {
log "Install STARTED"
npm install
check_exit
$(npm bin)/bower install --allow-root
check_exit
log "Install ENDED"
build
check_exit
}
build() {
log "Build STARTED"
$(npm bin)/grunt
log "Build ENDED"
}
watch() {
$(npm bin)/grunt watch
}
help() {
echo -e -n "$BLUE"
echo "-----------------------------------------------------------------------"
echo "- Available commands -"
echo "-----------------------------------------------------------------------"
echo " > install - Resolve npm and bower packages"
echo " > build - generates dist directory"
echo " > watch - watch for changes"
echo "-----------------------------------------------------------------------"
echo -e -n "$NORMAL"
}
if [ ! -f command.sh ]; then
error "Script must be run from project root-dir (ri-backoffice)"
exit -1
fi
if [ -z "$*" ]; then
help
else
$*
fi