mirror of
https://github.com/LukeSmithxyz/based.cooking.git
synced 2024-11-27 16:05:44 +00:00
parent
dda5820a33
commit
25fc33e066
45
.github/workflows/scripts/check-files.sh
vendored
45
.github/workflows/scripts/check-files.sh
vendored
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
check_file_name() {
|
||||||
|
fileName="$1"
|
||||||
|
expectedFolder="$2"
|
||||||
|
|
||||||
|
shouldname="${expectedFolder}/$(basename "$fileName" |
|
||||||
|
iconv --to-code=utf-8 |
|
||||||
|
tr '[:upper:]' '[:lower:]' |
|
||||||
|
tr '_ ' '-')"
|
||||||
|
|
||||||
|
if [ "$shouldname" != "$fileName" ]; then
|
||||||
|
echo "$1 should be named $shouldname."
|
||||||
|
FAIL=1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
check_webp_name() {
|
check_webp_name() {
|
||||||
shouldname="$(echo "$1" |
|
check_file_name "$1" "data/pix"
|
||||||
iconv --to-code=utf-8 |
|
|
||||||
sed "s/^\(data\/pix\/\)\?/data\/pix\//" |
|
|
||||||
tr '[:upper:]' '[:lower:]' |
|
|
||||||
tr '_ ' '-')"
|
|
||||||
if [ "$shouldname" != "$1" ]; then
|
|
||||||
echo "$1 should be named $shouldname."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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…
Reference in New Issue
Block a user