-
Notifications
You must be signed in to change notification settings - Fork 0
/
cdn-site-build
executable file
·43 lines (36 loc) · 1.2 KB
/
cdn-site-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
#!/bin/sh -eu
set -eu
# This script is registered as the entry-point for CloudFlare Pages to
# invoke to build the site. Do not rename this script without updating
# CloudFlare. We deliberately try to keep things simple, to reduce the
# risk of portability woes as CF update builder environments: we should
# be able to just stick to the latest release version, always.
#
# This script can invoke other tools for more complicated work.
# This script just copies some files into place. Simple shell work.
progname="$(basename "$0" .sh)"
warn() { printf >&2 '%s: %s\n' "$progname" "$*"; }
die() { warn "$@"; exit 1; }
readonly DEPLOY_DIR='public'
readonly DEPLOY_CONF='cdn-files.txt'
[ -f "$DEPLOY_CONF" ] || die "missing critical file: $DEPLOY_CONF (in $(pwd))"
if [ -d "$DEPLOY_DIR" ]; then
warn "removing pre-existing: $DEPLOY_DIR"
rm -rf -- "$DEPLOY_DIR"
fi
mkdir -v -- "$DEPLOY_DIR"
while read -r fn; do
[ -n "$fn" ] || continue
case "$fn" in
\#*) continue ;;
esac
d="$(dirname "$fn")"
if [ "$d" != "." ]; then
td="$DEPLOY_DIR/$d"
[ -d "$td" ] || mkdir -pv -- "$td"
else
td="$DEPLOY_DIR"
fi
cp -av "$fn" "$td/$fn"
done < "$DEPLOY_CONF"
"$(dirname "$0")/make-json-files" "$DEPLOY_DIR"