Skip to content

Instantly share code, notes, and snippets.

@leothorp
Last active January 31, 2023 05:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leothorp/79cf50b4bddf0b6d4299867df7bf7a1c to your computer and use it in GitHub Desktop.
Save leothorp/79cf50b4bddf0b6d4299867df7bf7a1c to your computer and use it in GitHub Desktop.
Husky post-merge hook: auto-update pnpm packages
#!/usr/bin/env sh
. "$(dirname "$0")/_/husky.sh"
# navigate to parent of husky dir- we assume pnpm-lock is located there.
cd "$(dirname $0)/.."
LOCKFILE_CHANGED_LINES=`git diff HEAD@{1} --stat -- pnpm-lock.yaml | wc -l`
if [ -z "${CI}" ] && [ $LOCKFILE_CHANGED_LINES -gt 0 ];
then
echo "Detected changes to lockfile. Reinstalling packages..."
pnpm i
fi
cd -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment