Makefile 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # Licensed under MIT.
  2. # Copyright (2016) by Kevin van Zonneveld https://twitter.com/kvz
  3. #
  4. # https://www.npmjs.com/package/fakefile
  5. #
  6. # This Makefile offers convience shortcuts into any Node.js project that utilizes npm scripts.
  7. # It functions as a wrapper around the actual listed in `package.json`
  8. # So instead of typing:
  9. #
  10. # $ npm script build:assets
  11. #
  12. # you could also type:
  13. #
  14. # $ make build-assets
  15. #
  16. # Notice that colons (:) are replaced by dashes for Makefile compatibility.
  17. #
  18. # The benefits of this wrapper are:
  19. #
  20. # - You get to keep the the scripts package.json, which is more portable
  21. # (Makefiles & Windows are harder to mix)
  22. # - Offer a polite way into the project for developers coming from different
  23. # languages (npm scripts is obviously very Node centric)
  24. # - Profit from better autocomplete (make <TAB><TAB>) than npm currently offers.
  25. # OSX users will have to install bash-completion
  26. # (http://davidalger.com/development/bash-completion-on-os-x-with-brew/)
  27. define npm_script_targets
  28. TARGETS := $(shell node -e 'for (var k in require("./package.json").scripts) {console.log(k.replace(/:/g, "-"));}')
  29. $$(TARGETS):
  30. npm run $(subst -,:,$(MAKECMDGOALS))
  31. .PHONY: $$(TARGETS)
  32. endef
  33. $(eval $(call npm_script_targets))
  34. # These npm run scripts are available, without needing to be mentioned in `package.json`
  35. install:
  36. npm install