ravenous_roll20/scripts/build.sh

47 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env sh
set -eu
repo_dir=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
cd "$repo_dir"
if ! command -v uv >/dev/null 2>&1; then
echo "uv is required: https://docs.astral.sh/uv/" >&2
exit 1
fi
uv sync --frozen
uv run python tools/build.py "$@"
output_dir=build
expect_output_dir=0
list_themes=0
check=0
for argument in "$@"; do
if [ "$expect_output_dir" -eq 1 ]; then
output_dir=$argument
expect_output_dir=0
continue
fi
case "$argument" in
--output-dir) expect_output_dir=1 ;;
--output-dir=*) output_dir=${argument#--output-dir=} ;;
--list-themes) list_themes=1 ;;
--check) check=1 ;;
esac
done
[ "$list_themes" -eq 1 ] && exit 0
example="$output_dir/example-character.json"
if [ "$check" -eq 1 ]; then
temporary=$(mktemp)
trap 'rm -f "$temporary"' EXIT HUP INT TERM
uv run python tools/generate_character.py --seed 20260919 --output "$temporary" >/dev/null
if ! cmp -s "$temporary" "$example"; then
echo "$example is missing or differs from the seeded character fixture" >&2
exit 1
fi
else
uv run python tools/generate_character.py --seed 20260919 --output "$example"
fi