Skip to content

Commit 1483869

Browse files
committed
[tools] Update spell-check.sh to handle SIGINT
1 parent b7d7e50 commit 1483869

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

tools/spell-check.sh

+6-5
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,14 @@ if [[ -n "$(git ls-files '*Cargo.toml')" ]]; then
4646
fi
4747
config_old=$(<.cspell.json)
4848
config_new=$(grep <<<"${config_old}" -v ' *//' | jq 'del(.dictionaries[])' | jq 'del(.dictionaryDefinitions[])')
49+
trap -- 'echo "${config_old}" >.cspell.json; echo >&2 "$0: trapped SIGINT"; exit 1' SIGINT
4950
echo "${config_new}" >.cspell.json
5051
if [[ -n "${has_rust}" ]]; then
51-
dependencies_words=$(npx <<<"${dependencies}" cspell stdin --no-progress --no-summary --words-only --unique || true)
52+
dependencies_words=$(npx <<<"${dependencies}" -y cspell stdin --no-progress --no-summary --words-only --unique || true)
5253
fi
53-
all_words=$(npx cspell --no-progress --no-summary --words-only --unique $(git ls-files | (grep -v "${project_dictionary//\./\\.}" || true)) || true)
54-
# TODO: handle SIGINT
54+
all_words=$(npx -y cspell --no-progress --no-summary --words-only --unique $(git ls-files | (grep -v "${project_dictionary//\./\\.}" || true)) || true)
5555
echo "${config_old}" >.cspell.json
56+
trap - SIGINT
5657
cat >.github/.cspell/rust-dependencies.txt <<EOF
5758
// This file is @generated by $(basename "$0").
5859
// It is not intended for manual editing.
@@ -62,8 +63,8 @@ if [[ -n "${dependencies_words:-}" ]]; then
6263
fi
6364
check_diff .github/.cspell/rust-dependencies.txt
6465

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

0 commit comments

Comments
 (0)