1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-29 16:02:51 -05:00

replace qmlformat with a better tool

still not perfect, but well - what can ya do
This commit is contained in:
bbedward
2025-08-08 15:55:37 -04:00
parent 8dc6e2805d
commit 4d408c65f2
137 changed files with 30315 additions and 29625 deletions

View File

@@ -1,44 +1,4 @@
#!/usr/bin/env bash
set -euo pipefail
QMLFORMAT_BIN=${QMLFORMAT_BIN:-qmlformat}
TMPDIR=$(mktemp -d)
find . -type f -name "*.qml" | while read -r file; do
original="$file"
tmp="$TMPDIR/formatted.qml"
pragmas="$TMPDIR/pragmas.txt"
errfile="$TMPDIR/qmlformat.err"
grep '^pragma ' "$original" > "$pragmas" || true
grep -v '^pragma ' "$original" > "$tmp"
if ! "$QMLFORMAT_BIN" -i "$tmp" 2> "$errfile"; then
echo "$original:"
cat "$errfile"
echo
# Extract all line numbers from error log
grep -oE 'formatted\.qml:([0-9]+)' "$errfile" | cut -d: -f2 | sort -n | uniq | while read -r lineno; do
echo "---- formatted.qml line $lineno (with context) ----"
# Show 2 lines before and after, numbering all lines
start=$((lineno - 2))
end=$((lineno + 2))
sed -n "${start},${end}p" "$tmp" | nl -ba
echo
done
echo "---- end of $original ----"
echo
continue
fi
if [[ -s "$pragmas" ]]; then
{ cat "$pragmas"; echo; cat "$tmp"; } > "$original"
else
cat "$tmp" > "$original"
fi
done
rm -rf "$TMPDIR"
# https://github.com/jesperhh/qmlfmt
find . -name "*.qml" -exec qmlfmt -t 2 -i 2 -w {} \;