Created
March 28, 2026 23:18
-
-
Save boris-42/a5497f7a2517d1d817b5933a0ec9e08c to your computer and use it in GitHub Desktop.
Working with monorepo
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
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| if [ $# -ne 1 ]; then | |
| echo "Usage: $0 <task-name>" | |
| exit 1 | |
| fi | |
| TASK_NAME="$1" | |
| SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" | |
| TASK_DIR="$SCRIPT_DIR/../$TASK_NAME" | |
| if [ -d "$TASK_DIR" ]; then | |
| echo "Error: directory '$TASK_DIR' already exists." | |
| exit 1 | |
| fi | |
| echo "==> Updating template..." | |
| "$SCRIPT_DIR/update.sh" | |
| echo "==> Copying template to '$TASK_NAME'..." | |
| cp -r "$SCRIPT_DIR" "$TASK_DIR" | |
| echo "==> Checking out branch '$TASK_NAME' in all submodules..." | |
| checkout_branch() { | |
| local path="$1" | |
| local branch="$2" | |
| git -C "$path" checkout -b "$branch" | |
| } | |
| cd "$TASK_DIR" | |
| pids=() | |
| for path in $(git submodule foreach --quiet 'echo $sm_path'); do | |
| checkout_branch "$path" "$TASK_NAME" & | |
| pids+=($!) | |
| done | |
| for pid in "${pids[@]}"; do | |
| wait "$pid" | |
| done | |
| echo "Done. Task directory: $TASK_DIR" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment