Skip to content

A local-first personal finance app

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

Matiss Janis Aboltins5b227f5fa129
diff --git a/.husky/post-checkout b/.husky/post-checkout
new file mode 100755
index 0000000000..b72113be3f
--- /dev/null
+++ b/.husky/post-checkout
@@ -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
diff --git a/upcoming-release-notes/7230.md b/upcoming-release-notes/7230.md
new file mode 100644
index 0000000000..037f4d714c
--- /dev/null
+++ b/upcoming-release-notes/7230.md
@@ -0,0 +1,6 @@
+---
+category: Maintenance
+authors: [MatissJanis]
+---
+
+Run `yarn install` when switching branches if `yarn.lock` changed