Skip to content

Commit

Permalink
chore(husky): limit the possibility of package installation after a b…
Browse files Browse the repository at this point in the history
…ranch switch

- add git hook `post-checkout`
  • Loading branch information
SimonGolms committed Jan 16, 2023
1 parent 4a71214 commit 256af00
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .husky/post-checkout
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

set +e
# Install any missing dependencies since package.json changed, while only versions changes are ignored.
git diff-tree -r --ignore-matching-lines="version" --name-only --no-commit-id "$1" "$2" | grep --quiet package.json && npm ci
set -e
4 changes: 2 additions & 2 deletions .husky/post-merge
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

# Install any missing dependencies since package.json changed
git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD | grep --quiet package.json && npm ci
# Install any missing dependencies since package.json changed, while only versions changes are ignored.
git diff-tree -r --ignore-matching-lines="version" --name-only --no-commit-id ORIG_HEAD HEAD | grep --quiet package.json && npm ci

0 comments on commit 256af00

Please sign in to comment.