-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecursive-vale-check-errors-only
More file actions
executable file
·37 lines (30 loc) · 1.08 KB
/
Copy pathrecursive-vale-check-errors-only
File metadata and controls
executable file
·37 lines (30 loc) · 1.08 KB
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
30
31
32
33
34
35
36
37
#!/bin/bash
# Function to find include files in a source file and run vale on them.
check_includes() {
local source_file="$1"
local source_dir="$(dirname "$source_file")"
# Filters for literal 'include::' paths, excluding attribute-based includes (which contain '{')
grep '^include::[^\{]*$' "$source_file" | \
awk -F'::|\\[' '{print $2}' | \
while read included_path; do
# Construct the absolute path
local full_path="$source_dir/$included_path"
# Check if the file exists and is not an attributes file
if [[ -f "$full_path" && "$included_path" != *"attributes"* ]]; then
echo "Linting: $full_path"
vale --minAlertLevel=warning "$full_path"
# Recursively check the included file
check_includes "$full_path"
fi
done
}
# Main execution logic
if [[ -z "$1" ]]; then
echo "Usage: $0 <path/to/master.adoc>"
exit 1
fi
echo "--- Checking Master File: $1 ---"
vale --minAlertLevel=warning "$1"
# Begin the recursive check
check_includes "$1"
echo "--- Recursive Check Complete ---"