mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-09 17:31:03 +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
|
||||
MIME_TYPE=$(file --mime-type -b "$file")
|
||||
[[ "$MIME_TYPE" != text/* ]] && continue
|
||||
|
||||
if [[ "$MIME_TYPE" == text/* ]]; then
|
||||
echo "Sanitizing $file"
|
||||
# 1️⃣ Replace exotic spaces → regular space
|
||||
# 2️⃣ Strip 0x0D (CR) at end of every line
|
||||
perl -CSD -pe "
|
||||
s/${UNICODE_SPACES_REGEX}/ /g; # space normalization
|
||||
s/\r$//; # CRLF → LF
|
||||
" "$file" > "$file.tmp" && mv "$file.tmp" "$file"
|
||||
else
|
||||
echo "Skipping non-text file: $file ($MIME_TYPE)"
|
||||
fi
|
||||
echo "Sanitizing $file"
|
||||
# Edit in place, preserving file permissions and metadata
|
||||
perl -i -CSD -pe "
|
||||
s/${UNICODE_SPACES_REGEX}/ /g; # space normalization
|
||||
s/\r$//; # CRLF → LF
|
||||
" "$file"
|
||||
done
|
||||
# ────────────────────────────────────────────────────────────────
|
||||
# 2. Ensure every *.sh script is executable
|
||||
|
||||
Reference in New Issue
Block a user