From 4573e873441b66808b028c163637795d1a0ce712 Mon Sep 17 00:00:00 2001 From: servostar Date: Tue, 3 Dec 2024 09:22:02 +0100 Subject: [PATCH] feat: consider included files and relative paths --- run-fmt.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/run-fmt.sh b/run-fmt.sh index b4fee1c..ffc07d9 100755 --- a/run-fmt.sh +++ b/run-fmt.sh @@ -17,7 +17,7 @@ function format() { exit 1 fi - local imports=$(rg "#import \"([a-z0-9/\-]+\.typ)\"" -Nor '$1' "$1") + local imports=$(rg "#import \"([a-z0-9/\-.]+\.typ)\"" -Nor '$1' "$1") # format all included files while IFS= read -r line; do @@ -26,6 +26,16 @@ function format() { fi format "$wd/$line" "$2" done <<< "$imports" + + local includes=$(rg "#import \"([a-z0-9/\-.]+\.typ)\"" -Nor '$1' "$1") + + # format all included files + while IFS= read -r line; do + if [ -z "$line" ]; then + continue + fi + format "$wd/$line" "$2" + done <<< "$includes" } case $1 in