X-Git-Url: https://git.yukkurigames.com/?p=string-lerp.git;a=blobdiff_plain;f=Makefile;h=22b272f653fc1913ce2f218573befcd451d56d94;hp=9d74d814373014d9620887c3aabea43fdab0f306;hb=39287ad87b41df055c4c7569b8e443051d182f1b;hpb=3632f64eb824b67f22c9694866ae369f7bc43080 diff --git a/Makefile b/Makefile index 9d74d81..22b272f 100644 --- a/Makefile +++ b/Makefile @@ -4,11 +4,10 @@ PKGNAME := string-lerp fallback = $(firstword $(shell command -v $(1)) $(2)) -git = $(shell GIT_DIR=$(firstword $(2) $(srcdir) .)/.git $(GIT) $(1)) -git_ls-tree = $(call git,ls-tree -r --name-only $(1),$(2)) -git_tag = $(call git,name-rev --tags --name-only $(call git,rev-parse $(1),$(2)),$(2)) - GIT ?= git +git_ls-tree = $(shell $(GIT) ls-tree -r --name-only $(1)) +git_tag = $(shell $(GIT) name-rev --tags --name-only $(shell $(GIT) rev-parse $(1))) + NPM ?= npm NPMBINDIR := ./node_modules/.bin JSTEST ?= $(NPMBINDIR)/jstest @@ -17,12 +16,14 @@ UGLIFY ?= $(call fallback,uglifyjs,$(NPMBINDIR)/uglifyjs) SOURCES := string-lerp.js UGLIFIED = $(SOURCES:.js=.min.js) +JSHINTFLAGS += --config tests/jshint.config + TESTS = $(wildcard tests/*.js) LINT_TARGETS = $(patsubst %.js,build/stamp/%.lint,$(SOURCES)) TEST_TARGETS = $(patsubst %.js,build/stamp/%.test,$(SOURCES)) \ $(patsubst tests/%.js,build/stamp/%.test,$(TESTS)) -.PHONY: all check lint test ugly dist clean distclean +.PHONY: all check lint test ugly dist clean distclean install all: @echo "Interesting targets:" @@ -31,7 +32,7 @@ all: @echo " ugly - generate minified/mangled source files" @echo " dist - generate redistributables (if git tagged)" @echo - @echo "(Running these may download packages from NPM.)" + @echo "(Running these may download packages from npm.)" @echo %.min.js: %.js | $(UGLIFY) @@ -39,7 +40,7 @@ all: build/stamp/%.lint: %.js | $(JSHINT) @mkdir -p $(@D) - $(JSHINT) $< + $(JSHINT) $(JSHINTFLAGS) $< @touch $@ build/stamp/%.test: tests/%.js %.js | $(JSTEST) @@ -68,12 +69,12 @@ build/dist/$(PKGNAME)-undefined.zip build/dist/$(PKGNAME)-undefined.tar.gz: .SECONDEXPANSION: build/dist/$(PKGNAME)-%.zip: $$(call git_ls-tree,$$*) @mkdir -p $(@D) - git archive --prefix=$(PKGNAME)-$*/ --output=$@ $* + $(GIT) archive --prefix=$(PKGNAME)-$*/ --output=$@ $* || ($(RM) $@ && exit 1) .SECONDEXPANSION: build/dist/$(PKGNAME)-%.tar.gz: $$(call git_ls-tree,$$*) @mkdir -p $(@D) - git archive --prefix=$(PKGNAME)-$*/ --output=$@ $* + $(GIT) archive --prefix=$(PKGNAME)-$*/ --output=$@ $* || ($(RM) $@ && exit 1) dist: check $(addprefix build/dist/$(PKGNAME)-$(call git_tag,HEAD),.zip .tar.gz) @@ -84,6 +85,9 @@ clean: distclean: clean $(RM) -r node_modules +install: check + $(NPM) install -g . + $(JSTEST): $(NPM) install jstest