Created
April 14, 2017 19:06
-
-
Save tlrobinson/b85df4137a3ebb78da955303e4994c5a to your computer and use it in GitHub Desktop.
This file contains 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 -eu | |
if [ $# -eq 2 ]; then | |
user=$1 | |
branch=$2 | |
elif [ $# -eq 1 ]; then | |
user=metabase | |
branch=$1 | |
else | |
echo "usage: $0 [USER] BRANCH" | |
exit 1 | |
fi | |
cd "$(dirname "$0")" | |
repo_path="$PWD/$user-$branch" | |
next_port_path="$PWD/next_port.txt" | |
if ! [[ -d "$repo_path" ]]; then | |
git clone -b "$branch" "[email protected]:$user/metabase.git" "$repo_path" | |
cd "$repo_path" | |
port="$(cat "$next_port_path" 2> /dev/null || echo "4000")" | |
echo "MB_JETTY_PORT=$port" >> ".env" | |
expr "$port" + 1 > "$next_port_path" | |
fi | |
osascript <<- EOF | |
tell application "iTerm" | |
tell current window | |
set sessionA to session of (create tab with profile "Default") | |
set sessionB to (split vertically sessionA with profile "Default") | |
write sessionA text "cd '$repo_path'" | |
write sessionA text "cat .env && foreman run lein run" | |
write sessionB text "cd '$repo_path'" | |
write sessionB text "yarn && yarn run build-watch" | |
end tell | |
end tell | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment