Created
July 11, 2024 04:45
-
-
Save third774/73d69c44ef59a273e20fd321d200ad78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Check if the RUN_TYPECHECKER_PRECOMMIT_HOOK environment variable is set to "true" | |
if [ "$RUN_TYPECHECKER_PRECOMMIT_HOOK" = "true" ]; then | |
echo "Running TypeScript type checker..." | |
# Run the TypeScript compiler in type-checking mode and capture the output | |
tsc_output=$(npx tsc --noEmit 2>&1) | |
tsc_exit_code=$? | |
# Check the exit code of the TypeScript compiler | |
if [ $tsc_exit_code -ne 0 ]; then | |
echo "TypeScript type check failed. Please fix the following errors before committing:" | |
echo "$tsc_output" | |
exit 1 | |
else | |
echo "TypeScript type check passed." | |
fi | |
else | |
echo "Skipping TypeScript type checker (RUN_TYPECHECKER_PRECOMMIT_HOOK is not set to 'true')." | |
fi | |
# If we've made it this far, the commit can proceed | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment