From bd34dd7fe3a7ea745ce2723b85cb2a3601ce1815 Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Thu, 6 Feb 2025 19:28:17 +0800 Subject: [PATCH] refactor(consolidate): add filename exclusions --- bin/consolidate | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/bin/consolidate b/bin/consolidate index 311854b..0e6e8ad 100755 --- a/bin/consolidate +++ b/bin/consolidate @@ -51,6 +51,9 @@ traverse_directory() { pattern=".*$" # Matches everything if no extensions specified fi + # Array of filenames to exclude from processing + local EXCLUDED_FILES=("LICENSE" ".gitignore") + # Loop through entries in the specified directory for entry in "$dir"/*; do if [[ -e "$entry" ]]; then # Check if the entry exists @@ -59,9 +62,19 @@ traverse_directory() { traverse_directory "$entry" # Recursive call fi elif [[ -f "$entry" ]]; then # Process files - if [[ "$(basename "$entry")" != ".gitignore" ]] && + # Check if the file should be excluded + local exclude=false + for excluded in "${EXCLUDED_FILES[@]}"; do + if [[ "$(basename "$entry")" == "$excluded" ]]; then + exclude=true + break + fi + done + + # Process the file only if it's not excluded, not ignored, and matches the pattern + if [[ "$exclude" == false ]] && ! is_ignored "$entry" && - [[ "$entry" =~ $pattern ]]; then # Check if file matches regex + [[ "$entry" =~ $pattern ]]; then process_file "$entry" # Process the file fi fi