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