Skip to content

Commit 78684d7

Browse files
committed
fail the script if the personal dictioanry file doesn't have the correct heading
1 parent 07ff87c commit 78684d7

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

scripts/check-doc-aspell

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
#!/usr/bin/env bash
22

3+
check_aspell_dict_header() {
4+
local dict_file="$1"
5+
local expected_lang="$2"
6+
7+
if [[ ! -f "$dict_file" ]]; then
8+
echo "Error: Dictionary file '$dict_file' does not exist"
9+
return 1
10+
fi
11+
12+
local first_line=$(head -n 1 "$dict_file")
13+
14+
# Check if first line matches the expected format: personal_ws-1.1 LANG NUMBER
15+
if [[ ! "$first_line" =~ ^personal_ws-1\.1[[:space:]]+${expected_lang}[[:space:]]+[0-9]+$ ]]; then
16+
echo "Error: Dictionary file '$dict_file' missing or invalid header"
17+
echo "Expected format: personal_ws-1.1 ${expected_lang} <word_count>"
18+
echo "Found: $first_line"
19+
return 1
20+
fi
21+
22+
return 0
23+
}
24+
325
echo "Checking spelling using aspell"
426

527
# Only support OSX and Linux for now
@@ -33,6 +55,12 @@ CHECK_LANG=en
3355
ASPELL_DICT_FILE="${ROOT_PATH}/scripts/aspell-dict-file.txt"
3456
ASPELL_IGNORE_PATH="${ROOT_PATH}/scripts/aspell-ignore/${CHECK_LANG}"
3557

58+
# Check if main aspell dictionary has proper header
59+
if ! check_aspell_dict_header "${ASPELL_IGNORE_PATH}/aspell-dict.txt" "$CHECK_LANG"; then
60+
echo "Please ensure aspell-dict.txt has the proper header format"
61+
exit 1
62+
fi
63+
3664
# Function to get a list of files
3765
get_files_to_check() {
3866
if [[ ! -z ${1:-} ]]; then

0 commit comments

Comments
 (0)