Skip to content

Commit

Permalink
fmt.sh: Render all d2 diagrams automatically
Browse files Browse the repository at this point in the history
Closes #1
  • Loading branch information
nhooyr committed Dec 8, 2022
1 parent 55e711b commit 580169c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions bin/fmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ trailing_whitespace() {
sh_c find . -name "'*.sedbak'" -delete
}

d2() {
if ! command -v d2 /dev/null && [ -n "${CI-}" ]; then
curl -fsSL https://d2lang.com/install.sh | sh -s --
fi
sh_c hide XARGS_N=1 xargsd "'\.\(d2\)$'" d2
}

main() {
job_parseflags "$@"
ensure_changed_files
Expand All @@ -65,6 +72,9 @@ main() {
if <"$CHANGED_FILES" xargs git grep -qIl ''; then
runjob trailing-whitespace trailing_whitespace &
fi
if <"$CHANGED_FILES" grep -qm1 '\.\(d2\)$'; then
runjob d2 &
fi
waitjobs
}

Expand Down

0 comments on commit 580169c

Please sign in to comment.