.PHONY: check build publish

build:
	$(MAKE) -C evening_detective_server build-linux
	npm --prefix evening_detective_frontend run build

publish:
	@test -n "$(MSG)" || (echo 'Usage: make publish MSG="commit message"' >&2; exit 1)
	@$(MAKE) build
	@set -e; \
	for repo in . evening_detective_server evening_detective_frontend; do \
		git -C "$$repo" add -A; \
		if git -C "$$repo" diff --cached --quiet; then \
			echo "$$repo: no changes"; \
			continue; \
		fi; \
		git -C "$$repo" commit -m "$(MSG)"; \
		git -C "$$repo" push; \
	done

check:
	$(MAKE) -C evening_detective_server test
	npm --prefix evening_detective_frontend run type-check
	npm --prefix evening_detective_frontend run lint
	npm --prefix evening_detective_frontend run lint:css
