add pre-commit hook for file size (#2206)

This commit is contained in:
Sean Holung
2022-11-10 10:29:27 -08:00
committed by GitHub
parent edd8882628
commit b7599957b2
2 changed files with 15 additions and 0 deletions
+2
View File
@@ -2,3 +2,5 @@
. "$(dirname -- "$0")/_/husky.sh"
yarn run lint-staged
./scripts/lint/check-file-size.sh
+13
View File
@@ -0,0 +1,13 @@
#! /bin/bash
# list files staged for commit
git diff --staged --name-only | \
while read line; do
# get size in bytes
size=$(wc -c "$line" | awk '{print $1}');
# verify staged files less than 1MB
if [ $((size)) -gt 1048576 ]; then
echo -e "\033[93m WARNING: $line greater than 1MB in size. \033[0m"
exit 1
fi
done