Skip to content

Commit

Permalink
[tools] Update spell-check.sh to handle SIGINT
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Oct 10, 2023
1 parent 0769aa9 commit a3d8568
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tools/spell-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ if [[ -n "$(git ls-files '*Cargo.toml')" ]]; then
fi
config_old=$(<.cspell.json)
config_new=$(grep <<<"${config_old}" -v ' *//' | jq 'del(.dictionaries[])' | jq 'del(.dictionaryDefinitions[])')
trap -- 'echo "${config_old}" >.cspell.json; echo >&2 "$0: trapped SIGINT"; exit 1' SIGINT
echo "${config_new}" >.cspell.json
if [[ -n "${has_rust}" ]]; then
dependencies_words=$(npx <<<"${dependencies}" cspell stdin --no-progress --no-summary --words-only --unique || true)
dependencies_words=$(npx <<<"${dependencies}" -y cspell stdin --no-progress --no-summary --words-only --unique || true)
fi
all_words=$(npx cspell --no-progress --no-summary --words-only --unique $(git ls-files | (grep -v "${project_dictionary//\./\\.}" || true)) || true)
# TODO: handle SIGINT
all_words=$(npx -y cspell --no-progress --no-summary --words-only --unique $(git ls-files | (grep -v "${project_dictionary//\./\\.}" || true)) || true)
echo "${config_old}" >.cspell.json
trap - SIGINT
cat >.github/.cspell/rust-dependencies.txt <<EOF
// This file is @generated by $(basename "$0").
// It is not intended for manual editing.
Expand All @@ -62,8 +63,8 @@ if [[ -n "${dependencies_words:-}" ]]; then
fi
check_diff .github/.cspell/rust-dependencies.txt

echo "+ npx cspell --no-progress --no-summary \$(git ls-files)"
if ! npx cspell --no-progress --no-summary $(git ls-files); then
echo "+ npx -y cspell --no-progress --no-summary \$(git ls-files)"
if ! npx -y cspell --no-progress --no-summary $(git ls-files); then
error "spellcheck failed: please fix uses of above words or add to ${project_dictionary} if correct"
fi

Expand Down

0 comments on commit a3d8568

Please sign in to comment.