mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-11 02:11:01 +01:00
Simplify file sanitization process in workflow
Refactor sanitization logic to handle text files directly without conditional checks.
This commit is contained in:
18
.github/workflows/onpush_builder.yaml
vendored
18
.github/workflows/onpush_builder.yaml
vendored
@@ -56,18 +56,14 @@ jobs:
|
|||||||
|
|
||||||
find . -type f | while read -r file; do
|
find . -type f | while read -r file; do
|
||||||
MIME_TYPE=$(file --mime-type -b "$file")
|
MIME_TYPE=$(file --mime-type -b "$file")
|
||||||
|
[[ "$MIME_TYPE" != text/* ]] && continue
|
||||||
|
|
||||||
if [[ "$MIME_TYPE" == text/* ]]; then
|
echo "Sanitizing $file"
|
||||||
echo "Sanitizing $file"
|
# Edit in place, preserving file permissions and metadata
|
||||||
# 1️⃣ Replace exotic spaces → regular space
|
perl -i -CSD -pe "
|
||||||
# 2️⃣ Strip 0x0D (CR) at end of every line
|
s/${UNICODE_SPACES_REGEX}/ /g; # space normalization
|
||||||
perl -CSD -pe "
|
s/\r$//; # CRLF → LF
|
||||||
s/${UNICODE_SPACES_REGEX}/ /g; # space normalization
|
" "$file"
|
||||||
s/\r$//; # CRLF → LF
|
|
||||||
" "$file" > "$file.tmp" && mv "$file.tmp" "$file"
|
|
||||||
else
|
|
||||||
echo "Skipping non-text file: $file ($MIME_TYPE)"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
# ────────────────────────────────────────────────────────────────
|
# ────────────────────────────────────────────────────────────────
|
||||||
# 2. Ensure every *.sh script is executable
|
# 2. Ensure every *.sh script is executable
|
||||||
|
|||||||
Reference in New Issue
Block a user