-
Notifications
You must be signed in to change notification settings - Fork 5
/
grunt-menu.sh
103 lines (80 loc) · 1.76 KB
/
grunt-menu.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
# NPM Version
NPM_VERSION="4.0.0"
# Formatting variables
BOLD=$(tput bold)
NORMAL=$(tput sgr0)
GREEN=$(tput setaf 2)
LBLUE=$(tput setaf 6)
RED=$(tput setaf 1)
PURPLE=$(tput setaf 5)
#==============
# Initiate and clone submodule
#==============
INSTALL_SUBMODULE() {
# Remove any trace of old modules
if [ -d ".git/modules/grunt-base" ]; then
rm -rf grunt-base
rm -rf .git/modules/grunt-base/
git submodule deinit grunt-base
git rm grunt-base
git rm --cached grunt-base
fi
# remove Gruntfile.js if exist
if [ -f Gruntfile.js ]; then
rm Gruntfile.js
fi
# remove package.json if exist
if [ -f package.json ]; then
rm package.json
fi
# Make sure you're in a git directory before trying to create a submodule
if [ -d ".git" ]; then
git submodule init
git submodule add https://gitlab.cwp.govt.nz/build-tools/grunt-base.git
else
git init
submodule;
fi
}
#==============
# Remove any old files and import new ones to project root
#==============
INSTALL_GRUNT() {
# Create syslinks
ln -s grunt-base/Gruntfile.js ./
ln -s grunt-base/package.json ./
# Install package.json dependencies
npm install
clear;
echo 'COMPLETE: Type "grunt" to start watching!';
exit;
}
#==============
# Menu
#==============
main() {
clear
until [ "$REPLY" = "q" ]
do
echo "${BOLD}#-----------------------------------------------#${NORMAL}"
echo
echo "${GREEN}1. Project setup ${NORMAL}"
echo "Install grunt and required modules for a clean project"
echo
echo '#-----------------------------------------------#'
echo 'q. Quit'
echo
read -p 'Command : ' REPLY
case $REPLY in
1) INSTALL_SUBMODULE && INSTALL_GRUNT
;;
[Qq]*) clear && exit
;;
esac
done
}
#==============
# Call the menu
#==============
main