diff --git a/tools/tidy.sh b/tools/tidy.sh index 0936383d..73c4d48a 100755 --- a/tools/tidy.sh +++ b/tools/tidy.sh @@ -170,30 +170,28 @@ if [[ -f .cspell.json ]]; then dependencies+=$(jq <<<"${metadata}" ".packages[] | select(.id == ${id})" | jq -r '.dependencies[].name') done done - words='' # shellcheck disable=SC2001 - for word in $(sed <<<"${dependencies}" 's/[0-9_-]/\n/g' | LC_ALL=C sort -f -u | (grep -E '.{4,}' || true)); do - # Skip if the word is contained in other dictionaries. - if ! npx cspell trace "${word}" 2>/dev/null | (grep -v -E '/(project-dictionary|rust-dependencies)\.txt' || true) | grep -Eq "^${word} \* [0-9A-Za-z_-]+\* "; then - words+=$'\n' - words+="${word}" - fi - done + dependencies=$(sed <<<"${dependencies}" 's/[0-9_-]/\n/g' | LC_ALL=C sort -f -u) + config_old=$(<.cspell.json) + config_new=$(grep <<<"${config_old}" -v ' *//' | jq 'del(.dictionaries[] | select(index("organization-dictionary") | not))' | jq 'del(.dictionaryDefinitions[] | select(.name == "organization-dictionary" | not))') + echo "${config_new}" >.cspell.json + words=$(npx <<<"${dependencies}" cspell stdin --no-progress --no-summary --words-only --unique || true) + echo "${config_old}" >.cspell.json fi cat >.github/.cspell/rust-dependencies.txt <>.github/.cspell/rust-dependencies.txt + echo $'\n'"${words}" >>.github/.cspell/rust-dependencies.txt fi check_diff .github/.cspell/rust-dependencies.txt if ! grep -Eq "^\.github/\.cspell/rust-dependencies.txt linguist-generated" .gitattributes; then echo "warning: you may want to mark .github/.cspell/rust-dependencies.txt linguist-generated" fi - echo "+ npx cspell --no-progress \$(git ls-files)" - npx cspell --no-progress $(git ls-files) + echo "+ npx cspell --no-progress --no-summary \$(git ls-files)" + npx cspell --no-progress --no-summary $(git ls-files) for dictionary in .github/.cspell/*.txt; do if [[ "${dictionary}" == .github/.cspell/project-dictionary.txt ]]; then