-
Notifications
You must be signed in to change notification settings - Fork 1
/
tools.sh
executable file
·47 lines (40 loc) · 1.02 KB
/
tools.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
#!/usr/bin/env bash
# Local Server
run_server() {
port=$(( ( RANDOM % 100 ) + 8000 ))
if [[ "$OSTYPE" == "linux-gnu" ]]; then
google-chrome http://localhost:$port
elif [[ "$OSTYPE" == "darwin"* ]]; then
open -a "Google Chrome" http://localhost:$port
else
echo "Navigate to http://localhost:$port in your (Chrome) browser"
fi
python --version | grep 'Python 3' &> /dev/null
if [ $? -eq 0 ]; then
python -m http.server $port
else
python -m HTTPServer $port
fi
}
# Package
package() {
cd ./build
build_name=build_$(date +%s).zip
zip -r $build_name ./*
mv $build_name ../builds/
cd ../
echo "Build located at $(pwd)/builds/$build_name"
}
# Build
build() {
rsync -avr --exclude='node_modules/' --exclude='dist/' --exclude='.cache/' --exclude='node_modules/' --exclude='.git*' --exclude='build/' --exclude='builds/' --exclude='.eslintrc.js' --exclude='tools.sh' ./ ./build/
package
}
while getopts “sb” opt; do
case $opt in
s ) run_server
;;
b ) build
;;
esac
done