-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathbuild
executable file
·42 lines (31 loc) · 967 Bytes
/
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
#!/bin/bash
set -e
verbose() {
! test -z "$VERBOSE"
}
verbose && echo "Running tests..."
# (TODO) Update test script to for Zig.
#tools/test
verbose && echo "Formatting code..."
tools/format
verbose && echo "Measuring line lengths..."
tools/measure
# SITE_DIR is the final location where we want generated content to be
SITE_DIR="public"
# GENERATE_DIR is where the content will be generated initially
GENERATE_DIR="$(mktemp -d)"
function cleanup() {
rm -rf "$GENERATE_DIR"
}
trap cleanup EXIT
verbose && echo "Generating HTML to $GENERATE_DIR..."
tools/generate $GENERATE_DIR
# In TESTING mode, make sure that the generated content is identical to
# what's already in SITE_DIR. If a difference is found, this script exits
# with an error.
if [[ ! -z "$TESTING" ]]; then
echo "Comparing $GENERATE_DIR with $SITE_DIR..."
diff -r "$GENERATE_DIR" "$SITE_DIR"
fi
verbose && echo "Copying $GENERATE_DIR to $SITE_DIR"
cp -rf "${GENERATE_DIR}/." "$SITE_DIR"