|
4 | 4 | # Get the folder path of the script
|
5 | 5 | script_folder="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
6 | 6 |
|
7 |
| -# Define the sibling folder containing markdown files |
8 |
| -folder_path="$script_folder/comfyui_embedded_docs/docs" |
| 7 | +# Set the base path |
| 8 | +base_path="$script_folder/comfyui_embedded_docs/docs" |
9 | 9 |
|
10 |
| -# Resolve the full path of the sibling folder |
11 |
| -resolved_folder_path="$(realpath "$folder_path")" |
| 10 | +# Check if base path exists |
| 11 | +if [ ! -d "$base_path" ]; then |
| 12 | + echo "Error: Base directory not found" |
| 13 | + exit 1 |
| 14 | +fi |
12 | 15 |
|
13 |
| -# Find all markdown files in the folder and subfolders |
14 |
| -markdown_files=$(find "$resolved_folder_path" -type f -name "*.md") |
| 16 | +# Set the target folder path |
| 17 | +if [ -n "$1" ]; then |
| 18 | + target_folder="$base_path/$1" |
| 19 | + if [ ! -d "$target_folder" ]; then |
| 20 | + echo "Error: Subdirectory not found" |
| 21 | + exit 1 |
| 22 | + fi |
| 23 | +else |
| 24 | + target_folder="$base_path" |
| 25 | +fi |
| 26 | + |
| 27 | +# Find all markdown files in the target folder and subfolders |
| 28 | +markdown_files=$(find "$target_folder" -type f -name "*.md") |
| 29 | + |
| 30 | +# Check if any markdown files were found |
| 31 | +if [ -z "$markdown_files" ]; then |
| 32 | + echo "No markdown files found" |
| 33 | + exit 0 |
| 34 | +fi |
| 35 | + |
| 36 | +echo "Fixing markdown files..." |
15 | 37 |
|
16 | 38 | # Loop through each markdown file and fix linting issues
|
17 | 39 | for file in $markdown_files; do
|
18 |
| - echo "Fixing linting issues for: $file" |
19 |
| - markdownlint --fix "$file" |
| 40 | + # Run markdownlint and capture its output |
| 41 | + output=$(markdownlint --fix "$file" 2>&1) |
| 42 | + |
| 43 | + # Only show output if the file was modified |
| 44 | + if [ -n "$output" ]; then |
| 45 | + relative_path=${file#$base_path/} |
| 46 | + echo "Updated: $relative_path" |
| 47 | + fi |
20 | 48 | done
|
21 | 49 |
|
22 |
| -echo "Markdown linting fixes completed!" |
| 50 | +echo "Done!" |
0 commit comments