Makefile 1.0 KB

123456789101112131415161718192021222324252627
  1. # This Makefile offers convience shortcuts into this codebase
  2. # it functions as a wrapper around the actual npm scripts, collected in `package.json`
  3. # So instead of typing:
  4. #
  5. # $ npm script build:assets
  6. #
  7. # you could also type:
  8. #
  9. # $ make build-assets
  10. #
  11. # Notice that colons (:) are replaced by dashes for Makefile compatibility.
  12. #
  13. # The benefits of this wrapper are:
  14. #
  15. # - You get to keep the the scripts package.json, which is more portable (Makefiles & Windows are harder to mix)
  16. # - Offer a polite way into the project for developers coming from different languages (npm scripts is obviously very Node centric)
  17. # - Profit from better autocomplete (make <TAB><TAB>) than npm currently offers. OSX users will have to install bash-completion (http://davidalger.com/development/bash-completion-on-os-x-with-brew/)
  18. define npm_script_targets
  19. TARGETS := $(shell node -e 'for (var k in require("./package.json").scripts) {console.log(k.replace(/:/g, "-"));}')
  20. $$(TARGETS):
  21. npm run $(MAKECMDGOALS:-=:)
  22. .PHONY: $$(TARGETS)
  23. endef
  24. $(eval $(call npm_script_targets))