Add check-style makefile target

This commit is contained in:
Hanzei 2018-10-12 13:38:18 +02:00
parent b9e17a1c5f
commit fbdb357823
No known key found for this signature in database
GPG key ID: 69A2DEFD98937BA0

View file

@ -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),)