-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
25 additions
and
1 deletion.
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 |
---|---|---|
@@ -1,4 +1,28 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
tsc --noEmit && npx lint-staged | ||
tsc --noEmit | ||
|
||
npx lint-staged | ||
|
||
# List of files to check. These should already be in gitignore, but this provides an additional layer of protection. | ||
# List of banned files to check against. Any staging (ex. .env.staging, .env.stg) or prod file will be rejected. | ||
# To test this, try adding a file with the name .env.blocked to your project and add '.env.b' to the banned_files array | ||
banned_files=(".env.p" ".env.s") | ||
|
||
# Get list of staged files from git | ||
staged_files=$(git diff --cached --name-only) | ||
|
||
# Loop through each staged file | ||
for staged_file in $staged_files; do | ||
# Loop through each banned file | ||
for banned_file in "${banned_files[@]}"; do | ||
# Check if the staged file contains the banned file pattern | ||
if grep -q "$banned_file" <<< "$staged_file"; then | ||
printf "\n" | ||
printf "\e[31mError: Banned file \e[1m'$staged_file'\e[0m\e[31m found in staged files\e[0m \n" | ||
printf "Please remove it and try again.\n" | ||
exit 1 | ||
fi | ||
done | ||
done |