-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild
executable file
·71 lines (59 loc) · 1.7 KB
/
build
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
#!/usr/bin/env sh
DESCRIPTION="
Wren 0.4 -- build script for Wren, a Jekyll theme
Description:
Attempts to builds the Jekyll site in the working directory
and then checks whether that build was successful.
Usage:
build [options]
Options:
--clean) Removes site output without building
--drafts) Build the site with drafts and serve it locally
--help) Show this message
--test) Build the site and clean up afterwards
--serve) Build the site and serve afterwards
"
# Colours for output formatting
RED="\033[0;31m"
GREEN="\033[0;32m"
RESET="\033[0m"
# Builds the website with the trace flag then perform a basic check
# for success be querying if the main page exists; exit(1) on fail
build() {
echo "Building the site..."
bundle exec jekyll build --trace
if test -e "./_site/index.html"; then
echo "${GREEN}Success!${RESET} The site has built correctly."
else
echo "${RED}Error!${RESET} The site doesn't seem to build."
exit 1
fi
}
# Removes site output and metadata files without building
clean() {
bundle exec jekyll clean
}
# Serve the site locally, including any drafted and archived posts
drafts() {
echo "Serving the site with drafts..."
bundle exec jekyll serve --trace --drafts
}
# Serve the site locally
serve() {
echo "Serving the site..."
bundle exec jekyll serve --trace
}
# Exit with an error code if an unknown flag was used
unknown() {
echo "${RED}Unknown flag${RESET}, see 'build --help'"
exit 1
}
case "$1" in
"") build;; # behaviour with no flag
"--clean") clean;;
"--drafts") build; drafts;;
"--help") printf "%s" "${DESCRIPTION}";;
"--serve") build; serve;;
"--test") build; clean;;
*) unknown;;
esac