| 1 | |
| 2 | BIN = ./node_modules/.bin |
| 3 | |
| 4 | CWD := $(shell pwd) |
| 5 | UGLIFY = $(CWD)/node_modules/.bin/uglifyjs |
| 6 | JSHINT = $(CWD)/node_modules/.bin/jshint |
| 7 | |
| 8 | clean: |
| 9 | @rm -f favico-*.min.js |
| 10 | |
| 11 | lint: |
| 12 | $(JSHINT) ./favico.js |
| 13 | |
| 14 | build: |
| 15 | make clean |
| 16 | make lint |
| 17 | VERSION=`node -pe "require('./package.json').version"` && \ |
| 18 | $(UGLIFY) -c -m --comments 'license' favico.js > "favico-$$VERSION.min.js" |
| 19 | |
| 20 | define release |
| 21 | VERSION=`node -pe "require('./bower.json').version"` && \ |
| 22 | NEXT_VERSION=`node -pe "require('semver').inc(\"$$VERSION\", '$(1)')"` && \ |
| 23 | node -e "\ |
| 24 | ['./bower.json', './package.json'].forEach(function (file) {\ |
| 25 | var j = require(file);\ |
| 26 | j.version = \"$$NEXT_VERSION\";\ |
| 27 | var s = JSON.stringify(j, null, 2);\ |
| 28 | require('fs').writeFileSync(file, s);\ |
| 29 | });\ |
| 30 | " && \ |
| 31 | git rm favico-*.min.js && \ |
| 32 | make build && \ |
| 33 | git add favico-*.min.js bower.json package.json && \ |
| 34 | git commit -m "release $$NEXT_VERSION" && \ |
| 35 | git tag "$$NEXT_VERSION" -m "release $$NEXT_VERSION" |
| 36 | endef |
| 37 | |
| 38 | release-patch: lint |
| 39 | @$(call release,patch) |
| 40 | |
| 41 | release-minor: lint |
| 42 | @$(call release,minor) |
| 43 | |
| 44 | release-major: lint |
| 45 | @$(call release,major) |
| 46 | |
| 47 | publish: |
| 48 | git push --tags origin HEAD:master |
| 49 | # todo: bower/npm publish |
| 50 | |
| 51 | .PHONY: clean lint build |