#!/bin/sh
# script/fmt-check-markdown: fail unless every .md is formatted the way
# script/fmt would leave it. Read-only.
#
# prettier is never installed on the host: it runs in a container built
# from Dockerfile.fmt, pinned by package.json and yarn.lock.
# --no-cache-filter is here for the reason script/lint gives: a cached
# build checks nothing.
#
# Its own script because script/cibuild runs this half alone, after the
# Dockerfile's lint stage has checked the Go.
set -eu

ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"

# Must match the markdown check stage name in Dockerfile.fmt.
stage=fmt-check

main() {
    cd "$ROOT"
    docker build \
        --progress=plain \
        --no-cache-filter="$stage" \
        --target "$stage" \
        -f Dockerfile.fmt \
        .
}

main "$@"
