common/git-hooks/pre-commit
#!/bin/sh
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
# Invoke the "rush prettier" custom command to reformat files whenever they
# are committed. The command is defined in common/config/rush/command-line.json
# and uses the "rush-prettier" autoinstaller.
node common/scripts/install-run-rush.js prettier || exit $?
ERROR_COLOR='\033[0;31m'
WARNING_COLOR='\033[0;33m'
STOP_COLOR='\033[0m'
if ! command -v gitleaks > /dev/null 2>&1
then
echo "${ERROR_COLOR}\nGitleaks not found. To commit you safely, you need to install it per the instructions at https://github.com/gitleaks/gitleaks.${STOP_COLOR}"
exit 1
elif [ "$SKIP" == "gitleaks" ]
then
echo "${WARNING_COLOR}\nGitleaks skipped for this commit.${STOP_COLOR}"
else
gitleaks protect -v --staged --report-path ./findings.json
fi