Makefile 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # get Makefile directory name: http://stackoverflow.com/a/5982798/376773
  2. THIS_MAKEFILE_PATH:=$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
  3. THIS_DIR:=$(shell cd $(dir $(THIS_MAKEFILE_PATH));pwd)
  4. # BIN directory
  5. BIN := $(THIS_DIR)/node_modules/.bin
  6. # Path
  7. PATH := node_modules/.bin:$(PATH)
  8. SHELL := /bin/bash
  9. # applications
  10. NODE ?= $(shell which node)
  11. YARN ?= $(shell which yarn)
  12. PKG ?= $(if $(YARN),$(YARN),$(NODE) $(shell which npm))
  13. BROWSERIFY ?= $(NODE) $(BIN)/browserify
  14. install: node_modules
  15. browser: dist/debug.js
  16. node_modules: package.json
  17. @NODE_ENV= $(PKG) install
  18. @touch node_modules
  19. dist/debug.js: src/*.js node_modules
  20. @mkdir -p dist
  21. @$(BROWSERIFY) \
  22. --standalone debug \
  23. . > dist/debug.js
  24. lint:
  25. @eslint *.js src/*.js
  26. test-node:
  27. @istanbul cover node_modules/mocha/bin/_mocha -- test/**.js
  28. @cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
  29. test-browser:
  30. @$(MAKE) browser
  31. @karma start --single-run
  32. test-all:
  33. @concurrently \
  34. "make test-node" \
  35. "make test-browser"
  36. test:
  37. @if [ "x$(BROWSER)" = "x" ]; then \
  38. $(MAKE) test-node; \
  39. else \
  40. $(MAKE) test-browser; \
  41. fi
  42. clean:
  43. rimraf dist coverage
  44. .PHONY: browser install clean lint test test-all test-node test-browser