2017-03-24 15:48:24 +00:00
|
|
|
ELM_FILES := $(shell find src -iname *.elm)
|
2017-05-12 14:49:32 +00:00
|
|
|
DOCKER_IMG :=elm-env
|
|
|
|
DOCKER_CMD := docker run --rm -t -v $(PWD):/app -w /app $(DOCKER_IMG)
|
2017-09-02 18:19:11 +00:00
|
|
|
# macOS requires mktemp template to be at the end of the filename.
|
|
|
|
TEMPFILE := $(shell mktemp ./elm-XXXXXXXXXX)
|
|
|
|
# --output flag for elm make must end in .js or .html.
|
|
|
|
TEMPFILE_JS := "$(TEMPFILE).js"
|
2017-04-21 16:42:29 +00:00
|
|
|
|
2017-05-12 14:49:32 +00:00
|
|
|
ifeq ($(NO_DOCKER), true)
|
|
|
|
DOCKER_CMD=
|
|
|
|
endif
|
|
|
|
|
|
|
|
all: test script.js
|
|
|
|
|
|
|
|
elm-env:
|
|
|
|
@(if [ "$(NO_DOCKER)" != "true" ] ; then \
|
|
|
|
echo ">> building elm-env docker image"; \
|
|
|
|
docker build -t $(DOCKER_IMG) ../. > /dev/null; \
|
|
|
|
fi; )
|
|
|
|
|
|
|
|
format: elm-env $(ELM_FILES)
|
|
|
|
@echo ">> format front-end code"
|
|
|
|
@$(DOCKER_CMD) elm-format --yes $(ELM_FILES)
|
|
|
|
|
|
|
|
test: elm-env
|
|
|
|
@$(DOCKER_CMD) elm-format $(ELM_FILES) --validate
|
|
|
|
@$(DOCKER_CMD) elm-test
|
2017-04-21 16:42:29 +00:00
|
|
|
|
|
|
|
dev-server:
|
2017-06-07 20:38:39 +00:00
|
|
|
elm-reactor
|
|
|
|
|
2017-05-12 14:49:32 +00:00
|
|
|
script.js: elm-env format $(ELM_FILES)
|
|
|
|
@echo ">> building script.js"
|
2017-09-02 18:19:11 +00:00
|
|
|
@$(DOCKER_CMD) elm make src/Main.elm --yes --output $(TEMPFILE_JS)
|
|
|
|
@$(DOCKER_CMD) uglifyjs $(TEMPFILE_JS) --compress unused --mangle --output $(@)
|
|
|
|
@rm -rf $(TEMPFILE_JS) $(TEMPFILE)
|
2017-05-12 14:49:32 +00:00
|
|
|
|
|
|
|
clean:
|
|
|
|
- @rm script.js
|
|
|
|
- @docker rmi $(DOCKER_IMG)
|