Skip to content

Instantly share code, notes, and snippets.

@hankadev
Created February 14, 2024 19:20
Show Gist options
  • Select an option

  • Save hankadev/b7ff6bc63fb99dec62fd74b2e706b4d6 to your computer and use it in GitHub Desktop.

Select an option

Save hankadev/b7ff6bc63fb99dec62fd74b2e706b4d6 to your computer and use it in GitHub Desktop.
a simple script for pre-commit hook that checks if I forgot to remove .only from a test case
#!/bin/bash
# pre-commit.sh
for file in $(git diff --cached --name-only | grep -E '\.(js|jsx|ts|tsx)$'); do
if grep -q ".only(" "$file"; then
echo "Error: '.only(' found in $file"
exit 1
fi
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment