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 |
|
5 | # BIN directory
|
6 | BIN := $(THIS_DIR)/node_modules/.bin
|
7 |
|
8 | # Path
|
9 | PATH := node_modules/.bin:$(PATH)
|
10 | SHELL := /bin/bash
|
11 |
|
12 | # applications
|
13 | NODE ?= $(shell which node)
|
14 | YARN ?= $(shell which yarn)
|
15 | PKG ?= $(if $(YARN),$(YARN),$(NODE) $(shell which npm))
|
16 | BROWSERIFY ?= $(NODE) $(BIN)/browserify
|
17 |
|
18 | install: node_modules
|
19 |
|
20 | browser: dist/debug.js
|
21 |
|
22 | node_modules: package.json
|
23 | @NODE_ENV= $(PKG) install
|
24 | @touch node_modules
|
25 |
|
26 | dist/debug.js: src/*.js node_modules
|
27 | @mkdir -p dist
|
28 | @$(BROWSERIFY) \
|
29 | --standalone debug \
|
30 | . > dist/debug.js
|
31 |
|
32 | lint:
|
33 | @eslint *.js src/*.js
|
34 |
|
35 | test-node:
|
36 | @istanbul cover node_modules/mocha/bin/_mocha -- test/**.js
|
37 | @cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
|
38 |
|
39 | test-browser:
|
40 | @$(MAKE) browser
|
41 | @karma start --single-run
|
42 |
|
43 | test-all:
|
44 | @concurrently \
|
45 | "make test-node" \
|
46 | "make test-browser"
|
47 |
|
48 | test:
|
49 | @if [ "x$(BROWSER)" = "x" ]; then \
|
50 | $(MAKE) test-node; \
|
51 | else \
|
52 | $(MAKE) test-browser; \
|
53 | fi
|
54 |
|
55 | clean:
|
56 | rimraf dist coverage
|
57 |
|
58 | .PHONY: browser install clean lint test test-all test-node test-browser
|