mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
chore(worktree): auto-run yarn install on new worktrees
Add a Claude Code SessionStart hook (matcher: startup) that runs `corepack yarn install` when node_modules is missing, so worktrees Claude creates internally are immediately usable. Also extend create-task-worktree.sh to install deps after the worktree is created, covering Codex/Cursor/manual flows that share that script.
This commit is contained in:
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
# SessionStart hook: ensure dependencies are installed for the current worktree.
|
||||
# Runs `corepack yarn install` when node_modules is missing, so new Claude-created
|
||||
# worktrees are usable immediately without a manual install step.
|
||||
|
||||
set -u
|
||||
|
||||
repo_root="${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"
|
||||
cd "$repo_root" 2>/dev/null || exit 0
|
||||
|
||||
# No yarn.lock → not a yarn project or fresh clone; nothing to do.
|
||||
[ -f "yarn.lock" ] || exit 0
|
||||
|
||||
# node_modules already populated → nothing to do (fast path).
|
||||
if [ -d "node_modules" ] && [ -n "$(ls -A node_modules 2>/dev/null | head -1)" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "[claude hook] node_modules missing in $repo_root — running corepack yarn install..."
|
||||
corepack yarn install
|
||||
exit 0
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"hooks": {
|
||||
"SessionStart": [
|
||||
{
|
||||
"matcher": "startup",
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/session-start.sh",
|
||||
"timeout": 600
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user