The template's files at a77fd30, without its history or LICENSE, after script/rename simplexcalc. Model: opus-5-5
27 lines
739 B
Bash
Executable File
27 lines
739 B
Bash
Executable File
#!/bin/sh
|
|
# script/fmt: format all files (writes). Go via gofmt, everything else
|
|
# (markdown, CSS, JS, YAML, JSON) via prettier with the repo's
|
|
# .prettierrc. Never hand-rolled substitutions: this script is the only
|
|
# sanctioned way to reformat the tree.
|
|
set -eu
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd -P)"
|
|
ROOT="$(cd "$SCRIPT_DIR/.." && pwd -P)"
|
|
|
|
main() {
|
|
cd "$ROOT"
|
|
|
|
gofmt -s -w .
|
|
|
|
if command -v goimports >/dev/null 2>&1; then
|
|
goimports -w .
|
|
fi
|
|
|
|
# A missing runner (exit 2) is a warning here: script/prettier has
|
|
# already said so on stderr, and failing `make fmt` over it would
|
|
# block work that has nothing to do with markdown.
|
|
"$SCRIPT_DIR/prettier" --write . || [ $? -eq 2 ]
|
|
}
|
|
|
|
main "$@"
|