Makefile 1.2 KB

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