-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathzprint-screens.sh
executable file
·32 lines (22 loc) · 1.08 KB
/
zprint-screens.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
DIRECTORY="backend/screens"
echo "Formatting Rabbit Screens"
# Find and format all Clojure, ClojureScript, and Clojure/ClojureScript files, excluding hidden directories
find "$DIRECTORY" -type f \( -name "*.edn" -o -name "*.rabbit" \) -print0 | while IFS= read -r -d '' file; do
#echo "Processing $file"
# Remove full-line comments
#sed -E '/^\s*;/d' "$file" > "$file.nocomments"
cp "$file" "$file.nocomments" ## to leave comments for now
# zprint formatting
echo "zprint formatting $file" ## :respect-nl :respect-bl preseves lots of formatting, be prevents lots of formatting changes... mixed bag
if ! zprint '{:style [:sort-require :ns-justify :justified-original] :parse-string? true :comment {:count? nil :wrap? nil} :width 120 :map {:comma? false :sort? false}}' < "$file.nocomments" > "$file.tmp"; then
echo "zprint failed for $file, skipping..."
rm -f "$file.nocomments" "$file.tmp"
continue
fi
# Move formatted file back to original
mv "$file.tmp" "$file"
# Clean up temporary file
rm -f "$file.nocomments"
done
echo "Formatting complete."