-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·58 lines (46 loc) · 1.55 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
#!/bin/bash
if [ -t 0 ] ; then # True if FD is opened on a terminal.
INTERACTIVE_MODE=true
red=$(tput setaf 1)
green=$(tput setaf 2)
yellow=$(tput setaf 3)
cyan=$(tput setaf 6)
reset=$(tput sgr0)
else
INTERACTIVE_MODE=false
fi
echoError() { echo -e "${red}$1${reset}" >&2; }
echoMessage() { echo -e "${cyan}$1${reset}" >&2; }
echoWarning() { echo -e "${yellow}$1${reset}" >&2; }
SCRIPT_DIR="$(dirname "$0")"
cd "${SCRIPT_DIR}"
if ! which npm > /dev/null; then
echoError "npm is missing, have you run the setup script (\"./setup.sh\") for installing TOC-it dependencies?"
exit 1
fi
if ! npm install; then
echoError "Something went wrong while installing dependencies through npm install"
exit 1
fi
if ! which browserify > /dev/null; then
echoError "Browserify is missing, have you run the setup script (\"./setup.sh\") for installing TOC-it dependencies?"
exit 1
fi
if ! browserify "index.js" -o "bundle.js"; then
echoError "Something went wrong while browserifying the index.js file"
exit 1
fi
if ! which uglifyjs > /dev/null; then
echoError "Uglifyjs is missing, have you run the setup script (\"./setup.sh\") for installing TOC-it dependencies?"
exit 1
fi
if ! uglifyjs --compress --mangle -- "bundle.js" > "bundle.min.js"; then
echoError "Something went wrong while uglifying the bundle.js file"
exit 1
fi
if ! rm "bundle.js"; then
echoWarning "Unable to remove temporary file bundle.js."
echoWarning "This may not be a big problem, so the script will continue"
fi
echoMessage "Done!"
exit 0