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 Jan 24, 2023
1 parent 23984e4 commit 9d1b586
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 @@ -48,6 +48,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 @@ -69,6 +76,9 @@ main() {
if <"$CHANGED_FILES" grep -q '\.\(js\|jsx\|ts\|tsx\|scss\|css\|html\)$'; then
runjob prettier &
fi
if <"$CHANGED_FILES" grep -qm1 '\.\(d2\)$'; then
runjob d2 &
fi
waitjobs
}

Expand Down

0 comments on commit 9d1b586

Please sign in to comment.