#!/bin/sh
# script/lint: run the linter, in docker only, by building the lint stage
# of the Dockerfile and nothing else; the build fails on any finding.
# --no-cache makes every run execute the linter: a cached build of an
# unchanged tree succeeds without linting anything. The tag makes each
# build replace the previous image instead of leaving an untagged one.
set -eu

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

main() {
    cd "$ROOT"
    docker build --no-cache \
        --target lint \
        -t "$("$SCRIPT_DIR/projectname")-lint" .
}

main "$@"
