diff --git a/lib/copy.sh b/lib/copy.sh index 6446400..2a17b58 100644 --- a/lib/copy.sh +++ b/lib/copy.sh @@ -331,10 +331,15 @@ copy_directories() { # Find directories matching the pattern # Use -path for patterns with slashes (e.g., vendor/bundle), -name for basenames # Note: case inside $() inside heredocs breaks Bash 3.2, so compute first + # Use -maxdepth 1 for simple basenames to avoid scanning entire repo (e.g., node_modules) + # Falls back to recursive search if shallow search finds nothing local find_results case "$pattern" in - */*) find_results=$(find . -type d -path "./$pattern" 2>/dev/null) ;; - *) find_results=$(find . -type d -name "$pattern" 2>/dev/null) ;; + */*) find_results=$(find . -type d -path "./$pattern" 2>/dev/null || true) ;; + *) find_results=$(find . -maxdepth 1 -type d -name "$pattern" 2>/dev/null || true) + if [ -z "$find_results" ]; then + find_results=$(find . -type d -name "$pattern" 2>/dev/null || true) + fi ;; esac while IFS= read -r dir_path; do