mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
qmlfmt: restoring error reporting
This commit is contained in:
+15
-4
@@ -1,8 +1,19 @@
|
||||
#!/usr/bin/env -S bash
|
||||
set -euo pipefail
|
||||
|
||||
# QML Formatter Script
|
||||
# Uses: https://github.com/jesperhh/qmlfmt
|
||||
# Can be installed from AUR "qmlfmt-git"
|
||||
# Requires qt6-5compat
|
||||
# Install: AUR package "qmlfmt-git" (requires qt6-5compat)
|
||||
|
||||
echo "Formatting $(find . -name "*.qml" | wc -l) files..."
|
||||
find . -name "*.qml" -print0 | xargs -0 -P "$(nproc)" -I {} qmlfmt -e -b 360 -t 2 -i 2 -w {}
|
||||
command -v qmlfmt &>/dev/null || { echo "qmlfmt not found" >&2; exit 1; }
|
||||
|
||||
format_file() { qmlfmt -e -b 360 -t 2 -i 2 -w "$1" || { echo "Failed: $1" >&2; return 1; }; }
|
||||
export -f format_file
|
||||
|
||||
mapfile -t files < <(find "${1:-.}" -name "*.qml" -type f)
|
||||
[ ${#files[@]} -eq 0 ] && { echo "No QML files found"; exit 0; }
|
||||
|
||||
echo "Formatting ${#files[@]} files..."
|
||||
printf '%s\0' "${files[@]}" | \
|
||||
xargs -0 -P "${QMLFMT_JOBS:-$(nproc)}" -I {} bash -c 'format_file "$@"' _ {} \
|
||||
&& echo "Done" || { echo "Errors occurred" >&2; exit 1; }
|
||||
Reference in New Issue
Block a user