-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpre-commit
More file actions
27 lines (22 loc) · 781 Bytes
/
pre-commit
File metadata and controls
27 lines (22 loc) · 781 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/zsh
# Add the local node_modules/.bin directory to the PATH
export PATH=$PATH:./node_modules/.bin
# Define a function to check for DONTCOMMIT or NOCOMMIT strings
function check_for_nocommit {
for file in $(git diff --cached --name-only); do
if grep -qi -E "NOCOMMIT|DON['’]?T" "$file"; then
echo "Commit aborted: Found 'DONTCOMMIT' or 'NOCOMMIT' in file: $file"
exit 1
fi
done
}
# Call the check_for_nocommit function
check_for_nocommit
# Check if Husky is being used in the current repository and run the local Husky pre-commit hook
if [ -f .husky/pre-commit ]; then
.husky/pre-commit || exit 1
fi
# Check if the local pre-commit hook script exists before sourcing it
if [ -f .git/hooks/pre-commit ]; then
source .git/hooks/pre-commit
fi