This repository has been archived by the owner on Jun 29, 2023. It is now read-only.
/
compile.sh
71 lines (62 loc) · 1.67 KB
/
compile.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
#consts
LIBRARY_COMBINE_PATH="build/combined/libraryCombined.js"
LIBRARY_MINIFY_PATH="build/minified/libraryMinified.js"
APP_COMBINE_PATH="build/combined/appCombined.js"
APP_MINIFY_PATH="build/minified/appMinified.js"
APP_SCRIPT_FOLDER="scripts/app/"
#set globals
PRODUCT_FOLDER="products/develop/"
RELEASE=0
if [ "$1" == "release" ];
then
PRODUCT_FOLDER="products/release/"
RELEASE=1
fi
#ensure folders exist
echo "-----------creating folders------------"
python combiner.py prep
#copy resources
echo "-----------copying resources-----------"
copyStyles="cp -R styles ""$PRODUCT_FOLDER"
eval $copyStyles
copyImages="cp -R images ""$PRODUCT_FOLDER"
eval $copyImages
copySounds="cp -R sounds ""$PRODUCT_FOLDER"
eval $copySounds
#lint individual files
echo "----------linting app scripts----------"
for entry in "$APP_SCRIPT_FOLDER"/*
do
jshint $entry
done
#combine, copy, and preprocess scripts
if [ $RELEASE -eq 1 ]
then
echo "----------combining scripts------------"
python combiner.py release strip phase1
fi
#minify scripts
if [ $RELEASE -eq 1 ]
then
echo "-----------minifying scripts-----------"
cmd="uglifyjs ""$APP_COMBINE_PATH"" --mangle --compress -o ""$APP_MINIFY_PATH"
eval $cmd
cmd="uglifyjs ""$LIBRARY_COMBINE_PATH"" --mangle --compress -o ""$LIBRARY_MINIFY_PATH"
eval $cmd
fi
#get things into product folder
echo "----preprocessing markup and scripts---"
if [ $RELEASE -eq 1 ]
then
python combiner.py release strip phase2
else
python combiner.py develop nostrip phase2
fi
#open the page
if [ $RELEASE -eq 0 ]
then
echo "-------------open page-----------------"
open="open $PRODUCT_FOLDER""default.html"
eval $open
fi
echo "----------------done-------------------"