mirror of
https://github.com/taiki-e/install-action.git
synced 2026-05-10 06:30:32 +00:00
Update tools/tidy.sh
This commit is contained in:
@@ -204,6 +204,7 @@ fi
|
|||||||
# Spell check (if config exists)
|
# Spell check (if config exists)
|
||||||
if [[ -f .cspell.json ]]; then
|
if [[ -f .cspell.json ]]; then
|
||||||
info "spell checking"
|
info "spell checking"
|
||||||
|
project_dictionary=.github/.cspell/project-dictionary.txt
|
||||||
if type -P npm &>/dev/null; then
|
if type -P npm &>/dev/null; then
|
||||||
has_rust=''
|
has_rust=''
|
||||||
if [[ -n "$(git ls-files '*Cargo.toml')" ]]; then
|
if [[ -n "$(git ls-files '*Cargo.toml')" ]]; then
|
||||||
@@ -227,7 +228,7 @@ if [[ -f .cspell.json ]]; then
|
|||||||
if [[ -n "${has_rust}" ]]; then
|
if [[ -n "${has_rust}" ]]; then
|
||||||
dependencies_words=$(npx <<<"${dependencies}" cspell stdin --no-progress --no-summary --words-only --unique || true)
|
dependencies_words=$(npx <<<"${dependencies}" cspell stdin --no-progress --no-summary --words-only --unique || true)
|
||||||
fi
|
fi
|
||||||
all_words=$(npx cspell --no-progress --no-summary --words-only --unique $(git ls-files | (grep -v '\.github/\.cspell/project-dictionary\.txt' || true)) || true)
|
all_words=$(npx cspell --no-progress --no-summary --words-only --unique $(git ls-files | (grep -v "${project_dictionary//\./\\.}" || true)) || true)
|
||||||
# TODO: handle SIGINT
|
# TODO: handle SIGINT
|
||||||
echo "${config_old}" >.cspell.json
|
echo "${config_old}" >.cspell.json
|
||||||
cat >.github/.cspell/rust-dependencies.txt <<EOF
|
cat >.github/.cspell/rust-dependencies.txt <<EOF
|
||||||
@@ -244,17 +245,17 @@ EOF
|
|||||||
|
|
||||||
echo "+ npx cspell --no-progress --no-summary \$(git ls-files)"
|
echo "+ npx cspell --no-progress --no-summary \$(git ls-files)"
|
||||||
if ! npx cspell --no-progress --no-summary $(git ls-files); then
|
if ! npx cspell --no-progress --no-summary $(git ls-files); then
|
||||||
error "spellcheck failed: please fix uses of above words or add to .github/.cspell/project-dictionary.txt if correct"
|
error "spellcheck failed: please fix uses of above words or add to ${project_dictionary} if correct"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Make sure the project-specific dictionary does not contain duplicated words.
|
# Make sure the project-specific dictionary does not contain duplicated words.
|
||||||
for dictionary in .github/.cspell/*.txt; do
|
for dictionary in .github/.cspell/*.txt; do
|
||||||
if [[ "${dictionary}" == .github/.cspell/project-dictionary.txt ]]; then
|
if [[ "${dictionary}" == "${project_dictionary}" ]]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
dup=$(sed '/^$/d' .github/.cspell/project-dictionary.txt "${dictionary}" | LC_ALL=C sort -f | uniq -d -i | (grep -v '//.*' || true))
|
dup=$(sed '/^$/d' "${project_dictionary}" "${dictionary}" | LC_ALL=C sort -f | uniq -d -i | (grep -v '//.*' || true))
|
||||||
if [[ -n "${dup}" ]]; then
|
if [[ -n "${dup}" ]]; then
|
||||||
error "duplicated words in dictionaries; please remove the following words from .github/.cspell/project-dictionary.txt"
|
error "duplicated words in dictionaries; please remove the following words from ${project_dictionary}"
|
||||||
echo "======================================="
|
echo "======================================="
|
||||||
echo "${dup}"
|
echo "${dup}"
|
||||||
echo "======================================="
|
echo "======================================="
|
||||||
@@ -263,13 +264,13 @@ EOF
|
|||||||
|
|
||||||
# Make sure the project-specific dictionary does not contain unused words.
|
# Make sure the project-specific dictionary does not contain unused words.
|
||||||
unused=''
|
unused=''
|
||||||
for word in $(grep -v '//.*' .github/.cspell/project-dictionary.txt || true); do
|
for word in $(grep -v '//.*' "${project_dictionary}" || true); do
|
||||||
if ! grep <<<"${all_words}" -Eq -i "^${word}$"; then
|
if ! grep <<<"${all_words}" -Eq -i "^${word}$"; then
|
||||||
unused+="${word}"$'\n'
|
unused+="${word}"$'\n'
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [[ -n "${unused}" ]]; then
|
if [[ -n "${unused}" ]]; then
|
||||||
error "unused words in dictionaries; please remove the following words from .github/.cspell/project-dictionary.txt"
|
error "unused words in dictionaries; please remove the following words from ${project_dictionary}"
|
||||||
echo "======================================="
|
echo "======================================="
|
||||||
echo -n "${unused}"
|
echo -n "${unused}"
|
||||||
echo "======================================="
|
echo "======================================="
|
||||||
|
|||||||
Reference in New Issue
Block a user