bolt.diy/.husky/pre-commit

32 lines
944 B
Plaintext
Raw Normal View History

#!/bin/sh
echo "🔍 Running pre-commit hook to check the code looks good... 🔍"
2024-12-02 21:53:22 +00:00
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # Load nvm if you're using i
echo "Running typecheck..."
which pnpm
if ! pnpm typecheck; then
2024-12-02 21:53:22 +00:00
echo "❌ Type checking failed! Please review TypeScript types."
echo "Once you're done, don't forget to add your changes to the commit! 🚀"
echo "Typecheck exit code: $?"
exit 1
fi
2024-12-02 21:53:22 +00:00
echo "Running lint..."
if ! pnpm lint; then
echo "❌ Linting failed! 'pnpm lint:fix' will help you fix the easy ones."
echo "Once you're done, don't forget to add your beautification to the commit! 🤩"
2024-12-02 21:53:22 +00:00
echo "lint exit code: $?"
exit 1
fi
2024-12-13 08:22:21 +00:00
# Update commit.json with the latest commit hash
COMMIT_HASH=$(git rev-parse HEAD)
echo "{ \"commit\": \"$COMMIT_HASH\" }" > app/commit.json
git add app/commit.json
echo "👍 All good! Committing changes..."