diff --git a/Makefile b/Makefile index 9491e06..9f01b2d 100644 --- a/Makefile +++ b/Makefile @@ -11,13 +11,39 @@ include build/setup.mk BUNDLE_NAME ?= $(PLUGIN_ID)-$(PLUGIN_VERSION).tar.gz # all, the default target, tests, builds and bundles the plugin. -all: test dist +all: check-style test dist # apply propagates the plugin id into the server/ and webapp/ folders as required. .PHONY: apply apply: ./build/bin/manifest apply +.PHONY: check-style +check-style: webapp/.npminstall gofmt + @echo Checking for style guide compliance + +ifneq ($(HAS_WEBAPP),) + cd webapp && npm run lint +endif + +gofmt: +ifneq ($(HAS_SERVER),) + @echo Running GOFMT + @for package in $$(go list ./server/...); do \ + echo "Checking "$$package; \ + files=$$(go list -f '{{range .GoFiles}}{{$$.Dir}}/{{.}} {{end}}' $$package); \ + if [ "$$files" ]; then \ + gofmt_output=$$(gofmt -d -s $$files 2>&1); \ + if [ "$$gofmt_output" ]; then \ + echo "$$gofmt_output"; \ + echo "gofmt failure"; \ + exit 1; \ + fi; \ + fi; \ + done + @echo "gofmt success"; +endif + # server/.depensure ensures the server dependencies are installed server/.depensure: ifneq ($(HAS_SERVER),)