-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
45 lines (27 loc) · 1.16 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
## Global binaries
BIN_NPM:=$(shell which npm)
BIN_MOCHA:=$(shell which mocha)
BIN_NYC:=$(shell which nyc)
.EXPORT_ALL_VARIABLES:
run:
check-binaries: bin-npm-exists bin-mocha-exists bin-nyc-exists
bin-%-exists: ;@which $(shell echo $@ | cut -d '-' -f 2) > /dev/null
install: install-js
install-js:
${BIN_NPM} install --include=dev
tests: tests-js
tests-js:
${BIN_MOCHA} --require ${ROOT_DIR}/index.js ${ROOT_DIR}/tests/*-test.js
coverage: coverage-js
coverage-js:
${BIN_NYC} --reporter=html --report-dir "reports/js" --exclude "tests/" ${BIN_MOCHA} --require ${ROOT_DIR}/index.js ${ROOT_DIR}/tests/*-test.js
valid-full-coverage: valid-full-coverage-js
valid-full-coverage-js:
$(eval PERCENT_COVERAGE_JS=$(shell ${BIN_NYC} --reporter=text --exclude "tests/" ${BIN_MOCHA} --require ${ROOT_DIR}/index.js ${ROOT_DIR}/tests/*-test.js | grep -E "^All files" | awk '{ print $$10 }'))
@if [ "$(PERCENT_COVERAGE_JS)" = "100" ]; then echo "OK"; else false; fi
clean:
rm -rf ${ROOT_DIR}/reports
rm -rf ${ROOT_DIR}/.nyc_output
clean-all: clean
rm -rf ${ROOT_DIR}/node_modules ${ROOT_DIR}/package-lock.json