#!/bin/sh # script/fmt: format all files (writes): the Go sources with gofmt, the # Markdown with prettier. prettier is never installed on the host: it # runs from the Dockerfile's prettier stage with the repository mounted, # as the calling user so the files it rewrites keep their owner. set -eu ROOT="$(cd "$(dirname "$0")/.." && pwd -P)" main() { cd "$ROOT" gofmt -s -w . image="$(docker build -q --target prettier .)" docker run --rm --user "$(id -u):$(id -g)" -v "$ROOT:/src" "$image" \ prettier --write '**/*.md' --tab-width 4 --prose-wrap always } main "$@"