2022-11-10 10:29:27 -08:00
|
|
|
#! /bin/bash
|
|
|
|
|
|
|
|
# list files staged for commit
|
|
|
|
git diff --staged --name-only | \
|
2023-01-18 12:53:09 -08:00
|
|
|
while read line; do
|
|
|
|
# ignore the generated bundles
|
|
|
|
if [[ $line == "themes/default/assets/css/bundle.css" || $line == "themes/default/assets/css/marketing.css" || $line == "themes/default/assets/js/bundle.js" || $line == "themes/default/assets/js/marketing.js" ]]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo $line
|
|
|
|
|
2022-11-10 10:29:27 -08:00
|
|
|
# get size in bytes
|
|
|
|
size=$(wc -c "$line" | awk '{print $1}');
|
2023-10-07 21:08:39 -07:00
|
|
|
# verify staged files less than 3MB
|
|
|
|
if [ $((size)) -gt 3000000 ]; then
|
|
|
|
echo -e "\033[93m WARNING: $line greater than 3MB in size. \033[0m"
|
2022-11-10 10:29:27 -08:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|