spellcheck.sh 832 B

1234567891011121314151617181920212223242526272829303132333435
  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. set +e
  16. docker run --rm -i --name spellcheck \
  17. -v "${PROJ_ROOT}"/scripts/spellcheck/dicts:/dicts \
  18. -v "$SCHEMA":/schema.json \
  19. ghcr.io/emqx/emqx-schema-validate:0.4.0 /schema.json
  20. result="$?"
  21. if [ "$result" -eq 0 ]; then
  22. echo "Spellcheck OK"
  23. exit 0
  24. fi
  25. echo "If this script finds a false positive (e.g. when it thinks that a protocol name is a typo),"
  26. echo "Add the word to dictionary in scripts/spellcheck/dicts"
  27. exit $result