#!/bin/sh set -eu export LANG=C.UTF-8 export JEKYLL_ENV=production for DICT in build-aux/spelling/*.txt; do sort "$DICT" | diff - "$DICT" || { echo "The $DICT dictionary is unsorted. To fix it, run:" >&2 echo " LANG=C.UTF-8 sort $DICT | sponge $DICT" >&2 exit 1 } done OUT="$(mktemp)" jekyll build --future --trace # shellcheck disable=2044 for f in $(find _site -type f -name '*.html'); do if ! echo "$f" | grep -qE '(/vendor/|TODOs.html)'; then l="$(head -n2 "$f" | tail -n1 | cut -d\" -f2)" CURR_DICT="$(mktemp)" cat build-aux/spelling/international.txt "build-aux/spelling/$l.txt" > "$CURR_DICT" hunspell -u3 -H -d "$l" -p "$CURR_DICT" "$f" | tee -a "$OUT" fi done if [ -s "$OUT" ]; then printf "\nvvv Mispelled words detected by hunspell.\n\n" cut -d\ -f2- < "$OUT" | sort | uniq printf "\n^^^\n" >&2 exit 1 else echo "No spelling errors detected" exit 0 fi