-
Notifications
You must be signed in to change notification settings - Fork 76
/
check-spelling.sh
executable file
·29 lines (28 loc) · 919 Bytes
/
check-spelling.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
# creates a file of spelling mistakes if there are any
errors=0
path="tests/spelling/"
mkdir -p "$path"
misspelled="$path"misspelled-words.txt
if [ -f "$misspelled" ]; then
rm "$misspelled"
fi
while read -r file; do
echo "$file" >>"$path"misspelled-words-temp.txt
aspell list --lang=en --encoding=utf-8 --personal=./.aspell.en.pws <"$file" | sort -u >>"$path"misspelled-words-temp.txt
if [ "$(wc -l <"$path"misspelled-words-temp.txt)" -ge 2 ]; then
echo >>"$path"misspelled-words-temp.txt
cat "$path"misspelled-words-temp.txt
cat "$path"misspelled-words-temp.txt >>"$path"misspelled-words.txt
errors=1
fi
: >"$path"misspelled-words-temp.txt
done < <(find . -name "*.md" -not -path "**/charts/*" -not -path "**/node_modules/*" -not -path "**/venv/*")
if [ -f "$path"misspelled-words-temp.txt ]; then
rm "$path"misspelled-words-temp.txt
fi
if [ "$errors" -ge 1 ]; then
exit 1
else
exit 0
fi