forked from Planeshifter/node-wandbox-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
158 lines (91 loc) · 2.23 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#############
# VARIABLES #
NPM ?= npm
NODE_ENV ?= test
KERNEL ?= $(shell uname -s)
ifeq ($(KERNEL), Darwin)
OPEN ?= open
else
OPEN ?= xdg-open
endif
# NOTES #
NOTES ?= 'TODO|FIXME|WARNING|HACK|NOTE'
# TAPE #
TAPE ?= ./node_modules/.bin/tape
TAP_REPORTER ?= ./node_modules/.bin/tap-spec
# ISTANBUL #
ISTANBUL ?= ./node_modules/.bin/istanbul
ISTANBUL_OUT ?= ./reports/coverage
ISTANBUL_REPORT ?= lcov
ISTANBUL_LCOV_INFO_PATH ?= $(ISTANBUL_OUT)/lcov.info
ISTANBUL_HTML_REPORT_PATH ?= $(ISTANBUL_OUT)/lcov-report/index.html
# JSHINT #
JSHINT ?= ./node_modules/.bin/jshint
JSHINT_REPORTER ?= ./node_modules/jshint-stylish
# FILES #
SOURCES ?= lib/*.js
TESTS ?= test/*.js
###########
# TARGETS #
# HELP #
.PHONY: help
help:
@echo ''
@echo 'Usage: make <cmd>'
@echo ''
@echo ' make help Print this message.'
@echo ' make notes Search for code annotations.'
@echo ' make test Run tests.'
@echo ' make test-cov Run tests with code coverage.'
@echo ' make view-cov View the most recent code coverage report.'
@echo ' make lint Run code linting.'
@echo ' make install Install dependencies.'
@echo ' make clean Clean the build directory.'
@echo ' make clean-node Remove Node dependencies.'
@echo ''
# NOTES #
.PHONY: notes
notes:
grep -Ern $(NOTES) $(SOURCES) $(TESTS)
# UNIT TESTS #
.PHONY: test test-tape
test: test-tape
test-tape: node_modules
NODE_ENV=$(NODE_ENV) \
NODE_PATH=$(NODE_PATH_TEST) \
$(TAPE) \
"$(TESTS)" \
| $(TAP_REPORTER)
# CODE COVERAGE #
.PHONY: test-cov test-istanbul-tape
test-cov: test-istanbul-tape
test-istanbul-tape: node_modules
NODE_ENV=$(NODE_ENV) \
NODE_PATH=$(NODE_PATH_TEST) \
$(ISTANBUL) cover \
--dir $(ISTANBUL_OUT) \
--report $(ISTANBUL_REPORT) \
$(TAPE) -- \
"$(TESTS)"
# COVERAGE REPORT #
.PHONY: view-cov view-istanbul-report
view-cov: view-istanbul-report
view-istanbul-report:
$(OPEN) $(ISTANBUL_HTML_REPORT_PATH)
# LINT #
.PHONY: lint lint-jshint
lint: lint-jshint
lint-jshint: node_modules
$(JSHINT) \
--reporter $(JSHINT_REPORTER) \
./
# NODE #
.PHONY: install clean-node
install: package.json
$(NPM) install
clean-node:
rm -rf node_modules
# CLEAN #
.PHONY: clean
clean:
rm -rf build