pave

Makefile

.DEFAULT_GOAL := help

SHELL  = /bin/bash
.SHELLFLAGS = -o pipefail -c

MADE ?= $(HOME)/made

# shfmt finds the .bash files in these dirs by itself, but not the .test files.
SOURCES = bin lib tests tests/*.test

.PHONY: all
all: fmt test ## Everything that's a must before committing: fmt, test.

.PHONY: help
help: ## Print info about all commands
	@echo "Commands:"
	@echo
	@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
		| awk 'BEGIN {FS = ":.*?## "}; {printf "    \033[01;32m%-20s\033[0m %s\n", $$1, $$2}'

.PHONY: setup
setup: ## One-time dev env setup: activate git hooks.
	git config core.hooksPath hack/git-hooks

.PHONY: fmt
fmt: ## Format source in place.
	shfmt -w $(SOURCES)

.PHONY: check
check: ## Verify-only and fast; run by the pre-commit hook on every commit.
	shfmt -d $(SOURCES)
	shellcheck -x -S warning bin/pave lib/*.bash tests/*.test tests/testlib.bash

.PHONY: test
test: ## Run all tests.
	for t in tests/*.test; do "$$t" || exit; done

.PHONY: install
install: ## Install into $(MADE)/pave/ (bin/ and lib/).
	rm -rf "$(MADE)/pave"
	mkdir -p "$(MADE)/pave"
	cp -R bin lib "$(MADE)/pave/"

Makefile · 1.1 KiB · 7240887182