Fixed some issues from last PR #400 (#402)

pull/313/head^2
Steven Hall 3 years ago committed by GitHub
parent dda5820a33
commit 25fc33e066
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2,37 +2,37 @@
set -eu set -eu
SIZE_LIMIT=150000 SIZE_LIMIT=150000
FAIL=0
check_size() { check_size() {
size="$(stat --printf="%s" "$1")" size="$(stat --printf="%s" "$1")"
if [ "$size" -gt "$SIZE_LIMIT" ]; then if [ "$size" -gt "$SIZE_LIMIT" ]; then
echo "File $1 is bigger than specified $SIZE_LIMIT limit" echo "File $1 is bigger than specified $SIZE_LIMIT limit"
exit 1 FAIL=1
fi fi
} }
check_webp_name() { check_file_name() {
shouldname="$(echo "$1" | fileName="$1"
expectedFolder="$2"
shouldname="${expectedFolder}/$(basename "$fileName" |
iconv --to-code=utf-8 | iconv --to-code=utf-8 |
sed "s/^\(data\/pix\/\)\?/data\/pix\//" |
tr '[:upper:]' '[:lower:]' | tr '[:upper:]' '[:lower:]' |
tr '_ ' '-')" tr '_ ' '-')"
if [ "$shouldname" != "$1" ]; then
if [ "$shouldname" != "$fileName" ]; then
echo "$1 should be named $shouldname." echo "$1 should be named $shouldname."
exit 1 FAIL=1
fi fi
} }
check_webp_name() {
check_file_name "$1" "data/pix"
}
check_recipe_name() { check_recipe_name() {
shouldname="$(echo "$1" | check_file_name "$1" "src"
iconv --to-code=utf-8 |
sed "s/^\(src\/\)\?/src\//" |
tr '[:upper:]' '[:lower:]' |
tr '_ ' '-')"
if [ "$shouldname" != "$1" ]; then
echo "$1 should be named $shouldname."
exit 1
fi
} }
check_recipe_content() { check_recipe_content() {
@ -103,7 +103,7 @@ check_recipe_content() {
' "$1" ' "$1"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
exit 1; FAIL=1
fi fi
} }
@ -115,7 +115,8 @@ git diff --name-only "$(git merge-base origin/master HEAD)" | while IFS= read -r
check_webp_name "$file" check_webp_name "$file"
;; ;;
.github/*.md) .github/*.md)
exit 0; # Ignore markdown files in .github
continue;
;; ;;
*.md) *.md)
check_recipe_name "$file" check_recipe_name "$file"
@ -123,3 +124,5 @@ git diff --name-only "$(git merge-base origin/master HEAD)" | while IFS= read -r
;; ;;
esac esac
done done
exit $FAIL

Loading…
Cancel
Save