-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathrender-templates.sh
More file actions
executable file
·45 lines (38 loc) · 1.05 KB
/
render-templates.sh
File metadata and controls
executable file
·45 lines (38 loc) · 1.05 KB
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
#!/usr/bin/env bash
# A simple script to check that a template can be rendered with a specific
# version of `typst` compiler.
#
# PREFIX=build .github/scripts/render-templates.sh 0.14.0
function render-template() {
local typstc=${1-typst}
local root=${2-.}
${typstc} compile "${root}/main.typ" \
--diagnostic-format=short \
--format=pdf \
--root="${root}"
}
typstc="typst"
if [ -n "${PREFIX}" ]; then
typstc="${PREFIX}/bin/$typstc"
fi
typst_version=${1}
if [ -n "${typst_version}" ]; then
typstc="${typstc}-${typst_version}"
fi
if ! command -pv "${typstc}" >/dev/null; then
echo "no typst v${typst_version} (${typstc}) compiler found"
exit 1
else
command "$typstc" -V
fi
roots=$(find -type f -iname 'typst.toml' -printf '%h\n')
if [ -z "${roots}" ]; then
echo 'no typst templates found: no `typst.toml` files'
exit 0
fi
rc=0 # Accumulate failures.
while IFS= read -r root; do
echo "try to render template located at ${root}"
render-template "$typstc" "$root" || rc=1
done <<< "${roots}"
exit "$rc"