Provision local node_modules in issue worktrees

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
dotta
2026-03-28 11:40:48 -05:00
parent 27accb1bdb
commit 22af797ca3
2 changed files with 143 additions and 0 deletions

View File

@@ -335,6 +335,44 @@ disable_seeded_routines() {
disable_seeded_routines
if [[ -f "$worktree_cwd/package.json" && -f "$worktree_cwd/pnpm-lock.yaml" ]]; then
needs_install=0
while IFS= read -r relative_path; do
[[ -n "$relative_path" ]] || continue
target_path="$worktree_cwd/$relative_path"
if [[ -L "$target_path" ]]; then
rm "$target_path"
needs_install=1
continue
fi
if [[ ! -e "$target_path" ]]; then
needs_install=1
fi
done < <(
cd "$base_cwd" &&
find . \
-mindepth 1 \
-maxdepth 3 \
-type d \
-name node_modules \
! -path './.git/*' \
! -path './.paperclip/*' \
| sed 's#^\./##'
)
if [[ "$needs_install" -eq 1 ]]; then
(
cd "$worktree_cwd"
pnpm install --frozen-lockfile
)
fi
exit 0
fi
while IFS= read -r relative_path; do
[[ -n "$relative_path" ]] || continue
source_path="$base_cwd/$relative_path"