Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .githooks/post-checkout
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh
#
# post-checkout hook: set up worktrees after creation
# Copies .env from the main worktree and runs pnpm install.
#
# Arguments: $1=prev HEAD, $2=new HEAD, $3=branch flag (1=branch checkout, 0=file checkout)

# Only run on branch checkouts
[ "$3" = "1" ] || exit 0

# Detect if this is a worktree (not the main working tree)
main_worktree="$(git worktree list --porcelain | head -1 | sed 's/^worktree //')"
current_worktree="$(git rev-parse --show-toplevel)"

[ "$main_worktree" != "$current_worktree" ] || exit 0

# Copy .env from the main worktree if it exists and we don't already have one
if [ -f "$main_worktree/.env" ] && [ ! -f "$current_worktree/.env" ]; then
cp "$main_worktree/.env" "$current_worktree/.env"
echo "post-checkout: copied .env from main worktree"
fi

# Run pnpm install if node_modules doesn't exist
if [ ! -d "$current_worktree/node_modules" ]; then
echo "post-checkout: running pnpm install..."
cd "$current_worktree" && pnpm install
fi
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ tsconfig.tsbuildinfo

# Claude local settings
.claude/*.local.json
.claude/worktrees/

# Playwright logs
playwright-report/
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"test:coverage:report": "vitest run --coverage --reporter=html",
"test:coverage:check": "vitest run --coverage",
"prepack": "pnpm run build && ([ -f node_modules/.bin/oclif ] && node_modules/.bin/oclif manifest || echo 'Skipping oclif commands in production')",
"prepare": "pnpm run build && CI=true ABLY_INTERACTIVE=false oclif manifest",
"prepare": "[ -d .git ] && [ -d .githooks ] && git config core.hooksPath .githooks || true; pnpm run build && CI=true ABLY_INTERACTIVE=false oclif manifest",
"postinstall": "[ \"$CI\" = \"true\" ] || (test -f ./dist/scripts/postinstall-welcome.js && node ./dist/scripts/postinstall-welcome.js || echo \"Skipping welcome script (not found)\")",
"preversion": "pnpm run prepare",
"version": "oclif readme && git add README.md",
Expand Down
Loading