-
Notifications
You must be signed in to change notification settings - Fork 105
/
Copy pathbuild_locally.sh
executable file
·64 lines (55 loc) · 1.45 KB
/
build_locally.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
#!/bin/bash -eu
# Locally build the Jekyl site for testing on Ubuntu 16.04
have_check_arg() {
for arg in "$@"; do
if [[ "${arg}" == "check" ]]; then
return 0
fi
done
return 1
}
have_noinstall() {
for arg in "$@"; do
if [[ "${arg}" == "noinstall" ]]; then
return 0
fi
done
return 1
}
################################################################################
# Begin Main Script
################################################################################
if [[ "$0" != "${BASH_SOURCE}" ]]; then
{
echo "This file is meant to be executed, not 'source'd:"
echo
echo " ./${BASH_SOURCE}"
} >&2
return 1
fi
# Environment
export GEM_HOME=$HOME/gems
export PATH=$HOME/gems/bin:$PATH
# Install dependencies, unless argument says to skip
if ! have_noinstall "$@"; then
sudo apt-get install ruby ruby-dev build-essential
gem install bundler -v 2.2.29
bundle install
fi
# Test website using same script as Travis
if have_check_arg "$@"; then
./.check_build.sh
fi
# Launch website
echo
echo "-------------------------------------"
echo "-------------------------------------"
echo "Preparing to open http://localhost:4000"
echo "Be sure to refresh auto-opened webpage"
#read -p "Press any key to start serving website..."
echo "-------------------------------------"
echo "-------------------------------------"
echo
xdg-open http://localhost:4000
# Start serving website locally
bundle exec jekyll serve