-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add husky for precommit hooks
- Loading branch information
1 parent
d641e5e
commit 9f3c016
Showing
3 changed files
with
71 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
NORMAL=$(tput sgr0) | ||
RED=$(tput setaf 1) | ||
|
||
exec < /dev/tty | ||
|
||
# Function to display a message with asterisks | ||
display_box() { | ||
local message="$1" | ||
local length=${#message} | ||
|
||
printf "\n" | ||
printf "%0.s*" $(seq 1 $((length + 6))) | ||
printf "\n" | ||
printf "*${RED} %s ${NORMAL}*\n" "$message" | ||
printf "%0.s*" $(seq 1 $((length + 6))) | ||
printf "\n" | ||
} | ||
|
||
# Function to display staged files in a box | ||
display_staged_files() { | ||
local files=$(git diff --cached --name-only) | ||
local file_count=$(echo $files | wc -l) | ||
echo "+-------------------+\n" | ||
echo "| Staged files |\n" | ||
echo "+-------------------+\n" | ||
if [ $file_count -gt 0 ]; then | ||
git diff --cached --name-only | sed 's/^/| /;s/$/ |/' | ||
else | ||
echo "| No files |\n" | ||
fi | ||
echo "+-------------------+\n" | ||
} | ||
|
||
display_staged_files | ||
echo "Did you add types for these changes?" | ||
read -p "Enter your response (yes/no): " response | ||
|
||
|
||
if [ "$response" != "yes" ]; then | ||
display_box "Error: Types not added. Please add types before committing." | ||
exit 1 | ||
fi |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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