Makefile 1.5 KB

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