Created
October 9, 2025 15:41
-
-
Save adamtester/9ed76467686b02d65a0438fe05c21875 to your computer and use it in GitHub Desktop.
Rollup script for agents
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rollup () { | |
| local -a exts=() | |
| local -a exclude_dirs=(node_modules dist .next) | |
| while (( $# )) | |
| do | |
| case "$1" in | |
| (-x | --exclude) shift | |
| IFS=',' read -r -a exclude_dirs <<< "${1:-}" ;; | |
| (*) exts+=("$1") ;; | |
| esac | |
| shift | |
| done | |
| (( ${#exts[@]} )) || exts=(ts tsx) | |
| local -a prune_expr=() | |
| if (( ${#exclude_dirs[@]} )) | |
| then | |
| prune_expr=(-type d \() | |
| local first=1 | |
| for d in "${exclude_dirs[@]}" | |
| do | |
| if (( first )) | |
| then | |
| prune_expr+=(-name "$d") | |
| first=0 | |
| else | |
| prune_expr+=(-o -name "$d") | |
| fi | |
| done | |
| prune_expr+=(\) -prune -o) | |
| fi | |
| local -a name_args=(-name 'package.json') | |
| for ext in "${exts[@]}" | |
| do | |
| name_args+=(-o -name "*.${ext}") | |
| done | |
| find . "${prune_expr[@]}" -type f \( "${name_args[@]}" \) -print0 | while IFS= read -r -d '' f | |
| do | |
| printf '%s\n```\n' "$f" | |
| cat "$f" | |
| printf '```\n\n' | |
| done | pbcopy | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment