Updated pre-commit to check for dead links, updated projects pages and new post
This commit is contained in:
+33
-10
@@ -1,9 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
GREEN='\033[0;32m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo "Running pre-commit checks..."
|
||||
|
||||
# Track overall success/failure
|
||||
OVERALL_RESULT=0
|
||||
|
||||
# Get list of staged markdown files
|
||||
STAGED_MD_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.md$' || true)
|
||||
|
||||
@@ -16,10 +20,12 @@ echo "Checking markdown files..."
|
||||
|
||||
# Check markdown formatting with markdownlint-cli
|
||||
if command -v markdownlint &> /dev/null; then
|
||||
markdownlint $STAGED_MD_FILES || {
|
||||
echo "❌ Markdown linting failed. Fix issues or use 'git commit --no-verify' to skip."
|
||||
exit 1
|
||||
}
|
||||
if ! markdownlint $STAGED_MD_FILES; then
|
||||
echo "❌ Markdown linting failed."
|
||||
OVERALL_RESULT=1
|
||||
else
|
||||
echo -e "${GREEN}✅ Markdownlint passed!${NC}"
|
||||
fi
|
||||
else
|
||||
echo "⚠️ markdownlint not found, skipping markdown linting"
|
||||
fi
|
||||
@@ -59,14 +65,31 @@ if command -v aspell &> /dev/null; then
|
||||
fi
|
||||
done
|
||||
if [ $MISSPELLED -eq 1 ]; then
|
||||
echo "Review spelling errors above. Add correct terms to .aspell.personal"
|
||||
echo "Use 'git commit --no-verify' to skip if needed."
|
||||
exit 1
|
||||
echo "❌ Spell check failed."
|
||||
OVERALL_RESULT=1
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "⚠️ aspell not found, skipping spell check"
|
||||
fi
|
||||
|
||||
echo "✅ Pre-commit checks passed!"
|
||||
exit 0
|
||||
# Link validation
|
||||
if [ -x "./scripts/check-links.sh" ]; then
|
||||
echo "Running link validation..."
|
||||
if ! ./scripts/check-links.sh $STAGED_MD_FILES; then
|
||||
echo "❌ Link validation failed."
|
||||
OVERALL_RESULT=1
|
||||
fi
|
||||
else
|
||||
echo "⚠️ Link checker script not found or not executable, skipping link validation"
|
||||
fi
|
||||
|
||||
# Final result
|
||||
if [ $OVERALL_RESULT -eq 0 ]; then
|
||||
echo "✅ Pre-commit checks passed!"
|
||||
exit 0
|
||||
else
|
||||
echo ""
|
||||
echo "❌ Some pre-commit checks failed. Fix issues or use 'git commit --no-verify' to skip."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user