spellcheck.sh 964 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. # ensure dir
  4. cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")/../.."
  5. PROJ_ROOT="$(pwd)"
  6. if [ -z "${1:-}" ]; then
  7. SCHEMA="${PROJ_ROOT}/_build/docgen/emqx/schema-en.json"
  8. else
  9. SCHEMA="$(realpath "$1")"
  10. fi
  11. if ! [ -f "$SCHEMA" ]; then
  12. echo "Schema file $SCHEMA does not exist; did you forget to run 'make emqx{,-enterprise}' ?"
  13. exit 1
  14. fi
  15. if [[ -t 1 ]];
  16. then
  17. DOCKER_TERMINAL_OPT="-t"
  18. else
  19. DOCKER_TERMINAL_OPT=""
  20. fi
  21. set +e
  22. # shellcheck disable=SC2086
  23. docker run --rm -i ${DOCKER_TERMINAL_OPT} --name spellcheck \
  24. -v "${PROJ_ROOT}"/scripts/spellcheck/dicts:/dicts \
  25. -v "$SCHEMA":/schema.json \
  26. ghcr.io/emqx/emqx-schema-validate:0.4.0 /schema.json
  27. result="$?"
  28. if [ "$result" -eq 0 ]; then
  29. echo "Spellcheck OK"
  30. exit 0
  31. fi
  32. echo "If this script finds a false positive (e.g. when it thinks that a protocol name is a typo),"
  33. echo "Add the word to dictionary in scripts/spellcheck/dicts"
  34. exit $result