2024-11-23 09:08:14 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
echo "🔍 Running pre-commit hook to check the code looks good... 🔍"
|
|
|
|
|
2024-12-13 10:33:29 +00:00
|
|
|
# Load NVM if available (useful for managing Node.js versions)
|
2024-12-02 21:53:22 +00:00
|
|
|
export NVM_DIR="$HOME/.nvm"
|
2024-12-13 10:33:29 +00:00
|
|
|
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
2024-12-02 21:53:22 +00:00
|
|
|
|
2024-12-13 10:33:29 +00:00
|
|
|
# Ensure `pnpm` is available
|
|
|
|
echo "Checking if pnpm is available..."
|
|
|
|
if ! command -v pnpm >/dev/null 2>&1; then
|
|
|
|
echo "❌ pnpm not found! Please ensure pnpm is installed and available in PATH."
|
|
|
|
exit 1
|
|
|
|
fi
|
2024-12-02 21:53:22 +00:00
|
|
|
|
2024-12-13 10:33:29 +00:00
|
|
|
# Run typecheck
|
|
|
|
echo "Running typecheck..."
|
2024-11-23 09:08:14 +00:00
|
|
|
if ! pnpm typecheck; then
|
2024-12-13 10:33:29 +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! 🚀"
|
|
|
|
exit 1
|
2024-11-23 09:08:14 +00:00
|
|
|
fi
|
|
|
|
|
2024-12-13 10:33:29 +00:00
|
|
|
# Run lint
|
2024-12-02 21:53:22 +00:00
|
|
|
echo "Running lint..."
|
2024-11-23 09:08:14 +00:00
|
|
|
if ! pnpm lint; then
|
2024-12-13 10:33:29 +00:00
|
|
|
echo "❌ Linting failed! Run 'pnpm lint:fix' to fix the easy issues."
|
2024-11-23 09:08:14 +00:00
|
|
|
echo "Once you're done, don't forget to add your beautification to the commit! 🤩"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-12-13 08:22:21 +00:00
|
|
|
# Update commit.json with the latest commit hash
|
2024-12-13 10:33:29 +00:00
|
|
|
echo "Updating commit.json with the latest commit hash..."
|
2024-12-13 08:22:21 +00:00
|
|
|
COMMIT_HASH=$(git rev-parse HEAD)
|
2024-12-13 10:33:29 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "❌ Failed to get commit hash. Ensure you are in a git repository."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-12-13 08:22:21 +00:00
|
|
|
echo "{ \"commit\": \"$COMMIT_HASH\" }" > app/commit.json
|
|
|
|
git add app/commit.json
|
|
|
|
|
2024-12-13 10:33:29 +00:00
|
|
|
echo "👍 All checks passed! Committing changes..."
|