Skip to content

Commit

Permalink
Add a pre-commit hook
Browse files Browse the repository at this point in the history
To prevent accidentally committing .npmrc with the registry set to local.
  • Loading branch information
psrpinto committed Dec 6, 2024
1 parent a644e63 commit e3a790e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ for file in $STAGED_FILES; do
fi
done

exit 0
# Prevent commiting .npmrc with the registry set to local.
HAS_LOCAL_REGISTRY=$(git diff --cached --name-only .npmrc | xargs grep -n "registry=http://localhost:4873/")
if [ -n "${HAS_LOCAL_REGISTRY}" ]; then
echo "The commit was rejected due to attempting to commit .npmrc with the registry set to the local registry."
echo "Please undo that change to .npmrc."
exit 1
fi

exit 0

0 comments on commit e3a790e

Please sign in to comment.