-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sh
executable file
·126 lines (99 loc) · 2.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
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash -
###########################
## Environment Variables ##
###########################
# NOTE: Use these whenever directory structure needs to be referenced.
# This can be done in Node with `process.env`.
# Don't redefine these variables somewhere in JS or anywhere else.
# This is in line with the DRY principle of software engineering.
# NOTE: If sourcing this script, do so only from the project root.
# Otherwise $ROOT will have the wrong value.
# NOTE: Branding is captured by the variables ORGANISATION and APPNAME.
# It is possible to rebrand the app by just changing these two variables.
export ORGANISATION="NUS Students' Computing Club"
export APPNAME="Computing Club Email Blast"
export ROOT=`pwd`
export BIN=${ROOT}/node_modules/.bin
export LIB=${ROOT}/node_modules
export SRC=${ROOT}/src
export TESTS=${ROOT}/tests
export TMP=${ROOT}/tmp
export HTML=${SRC}/html
export CSS=${SRC}/css
export IMG=${SRC}/img
#####################
## Build Functions ##
#####################
# NOTE: All build functions must exit with a appropriate status code.
function doStart {
createDirectoryIfNotExists ${TMP}
startAppInElectron ${SRC}/main.js
local appStartStatusCode=$?
deleteDirectoryIfExists ${TMP}
return ${appStartStatusCode}
}
function doPackage {
echo "NOT IMPLEMENTED YET!"
exit 1
}
function doTest {
echo "NOT IMPLEMENTED YET!"
exit 1
}
function doCompile {
echo "NOT IMPLEMENTED YET"
exit 1
}
function doClean {
echo "NOT IMPLEMENTED YET!"
exit 1
}
######################
## Helper Functions ##
######################
function createDirectoryIfNotExists {
local dirToCreate=$1
if [ ! -d ${dirToCreate} ]; then
mkdir ${dirToCreate}
fi
}
function deleteDirectoryIfExists {
local dirToDelete=$1
if [ -d ${dirToDelete} ]; then
rm -rf ${dirToDelete}
fi
}
function startAppInElectron {
local entryPoint=$1
if [ -f ${entryPoint} ]; then
${BIN}/electron ${entryPoint}
return 0
else
echo "The entry point ${entryPoint} was not found."
return 1
fi
}
#####################################
## Command Line Parameter Handling ##
#####################################
case $1 in
"start")
doStart
;;
"package")
doPackage
;;
"test")
doTest
;;
"compile")
doCompile
;;
"clean")
doClean
;;
*)
# NOTE: DO NOT EXIT HERE!
# This is to allow sourcing of this script for env vars.
:
esac