diff options
author | EuAndreh <eu@euandre.org> | 2019-06-01 00:32:20 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2019-06-01 00:41:29 -0300 |
commit | 39112c6771409d5b2870052308980359a36d3159 (patch) | |
tree | 31574f66e6b847c71baf2b6c70cb2c8b9928b0a0 /spelling/check-spelling.sh | |
parent | Use pinned version of hakyll (diff) | |
download | euandre.org-39112c6771409d5b2870052308980359a36d3159.tar.gz euandre.org-39112c6771409d5b2870052308980359a36d3159.tar.xz |
Move test code out of default.nix
- use common utils.nix code for generic test derivation;
- move spell checking code into standalone Bash file.
Diffstat (limited to '')
-rwxr-xr-x | spelling/check-spelling.sh | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spelling/check-spelling.sh b/spelling/check-spelling.sh new file mode 100755 index 0000000..7656dc4 --- /dev/null +++ b/spelling/check-spelling.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +set -Eeuo pipefail + +HTML_DIR="${1:-}" +[[ -z "${HTML_DIR}" ]] && { + echo 'Undefined HTML_DIR.' + exit 2 +} + +# Required by =sort= and =hunspell= +export LANG=C.UTF-8 + +for DICT in spelling/*.txt; do + diff <(sort $DICT) $DICT || { + echo "The $DICT dictionary is unsorted. To fix it, run:" + echo " LANG=C.UTF-8 sort $DICT | sponge $DICT" + exit 1 + } +done + +hunspell -l -p <(cat spelling/international.dic.txt spelling/en_US.dic.txt spelling/en_US.aff.txt) -d en_US -i utf-8 $(find "$HTML_DIR" -type f -name '*.html') | tee spelling.txt +cat spelling.txt +[[ -s spelling.txt ]] && { + echo "Mispelled words detected by hunspell." + cat spelling.txt + exit 1 +} || { + echo "No words mispelled" +} |