feat: Add post-checkout hook to run yarn install if yarn.lock changes (#7230)

This commit is contained in:
Matiss Janis Aboltins
2026-03-17 15:58:02 +00:00
committed by GitHub
parent e1606b31ab
commit 5b227f5fa1
2 changed files with 19 additions and 0 deletions

13
.husky/post-checkout Executable file
View File

@@ -0,0 +1,13 @@
#!/bin/sh
# Run yarn install when switching branches (if yarn.lock changed)
# $3 is 1 for branch checkout, 0 for file checkout
if [ "$3" != "1" ]; then
exit 0
fi
# Check if yarn.lock changed between the old and new HEAD
if git diff --name-only "$1" "$2" | grep -q "^yarn.lock$"; then
echo "yarn.lock changed — running yarn install..."
yarn install
fi

View File

@@ -0,0 +1,6 @@
---
category: Maintenance
authors: [MatissJanis]
---
Run `yarn install` when switching branches if `yarn.lock` changed