-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
63 lines (49 loc) · 1.91 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
.PHONY: help test test-types check-cover view-cover npm-test travis-test clean
BIN = ./node_modules/.bin
# Determine reporter
reporter=tap
ifdef npm_config_dot
reporter=dot
endif
ifdef npm_config_spec
reporter=spec
endif
all: help
help:
@echo
@echo "To run tests:"
@echo " npm test [--dot | --spec] [--coverage | --grep=<test file pattern>]"
@echo
lint:
@$(BIN)/jshint .
test: node_modules
$(if $(npm_config_grep), @echo "Running test files that match pattern: $(npm_config_grep)\n",)
$(if $(filter tap, $(reporter)), @find ./test -maxdepth 1 -name "*.js" -type f | grep ""$(npm_config_grep) | xargs $(BIN)/istanbul cover --report lcovonly --print none $(BIN)/tape --)
$(if $(filter dot, $(reporter)), @find ./test -maxdepth 1 -name "*.js" -type f | grep ""$(npm_config_grep) | xargs $(BIN)/istanbul cover --report lcovonly --print none $(BIN)/tape -- | $(BIN)/tap-dot)
$(if $(filter spec, $(reporter)), @find ./test -maxdepth 1 -name "*.js" -type f | grep ""$(npm_config_grep) | xargs $(BIN)/istanbul cover --report lcovonly --print none $(BIN)/tape -- | $(BIN)/tap-spec)
ifdef npm_config_coverage
@echo
@$(BIN)/istanbul report text | grep -v "Using reporter" | grep -v "Done"
endif
@$(BIN)/istanbul report html > /dev/null
test-types: node_modules
@echo 'Running types tests (via tsd)'
@$(BIN)/tsd
npm-test: lint test check-cover test-types
travis-test: npm-test
@(cat coverage/lcov.info | coveralls) || exit 0
check-cover: coverage
@rm -f coverage/error
@$(BIN)/istanbul check-coverage --statements 100 --branches 100 --functions 100 --lines 100 2>&1 | cat > coverage/error
$(if $(npm_config_grep),,@if [ -s coverage/error ]; then echo; grep ERROR coverage/error; echo; exit 1; fi)
view-cover: coverage
@$(BIN)/opn coverage/index.html
coverage:
@make test
node_modules:
@echo '# *** running "npm install" for you ***'
@npm install
@mkdir -p node_modules
@touch node_modules
clean:
@rm -rf node_modules coverage