23 lines
792 B
Bash
Executable File
23 lines
792 B
Bash
Executable File
#!/bin/sh
|
|
|
|
# Using `--silent` helps for showing any errs in the first line of the response
|
|
# The first line is picked up by the VS Code GIT UI popup when rc is not 0
|
|
|
|
if npm run --silent lint:check:silent ; then
|
|
exit 0
|
|
else
|
|
npm run --silent lint:fix:silent
|
|
echo "❌ Prettier check failed! We ran lint:fix for you. Please add & commit again."
|
|
exit 1
|
|
fi
|
|
|
|
## Avoid large commits
|
|
# https://www.backblaze.com/blog/how-many-bytes-are-in-a-megabyte-really/
|
|
size_limit=$((2 * 2**20)) # 2mbs
|
|
# https://git-scm.com/docs/git-rev-list#Documentation/git-rev-list.txt---disk-usage
|
|
commit_size=$(git rev-list --disk-usage HEAD^..HEAD)
|
|
test "$commit_size" -lt "$size_limit" || (
|
|
echo "Commit size is too large: $commit_size > $size_limit"
|
|
echo "Force commit using --no-verify"
|
|
exit 1
|
|
) |