-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
144 lines (83 loc) · 1.85 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
#############
# VARIABLES #
# Set the node.js environment to test:
NODE_ENV ?= test
# Kernel name:
KERNEL ?= $(shell uname -s)
ifeq ($(KERNEL), Darwin)
OPEN ?= open
else
OPEN ?= xdg-open
endif
# NOTES #
NOTES ?= 'TODO|FIXME|WARNING|HACK|NOTE'
# MOCHA #
MOCHA ?= ./node_modules/.bin/mocha
_MOCHA ?= ./node_modules/.bin/_mocha
MOCHA_REPORTER ?= 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/stylish.js
# FILES #
# Source files:
SOURCES ?= lib/*.js
# Test files:
TESTS ?= test/*.js
###########
# TARGETS #
# NOTES #
.PHONY: notes
notes:
grep -Ern $(NOTES) $(SOURCES) $(TESTS)
# UNIT TESTS #
.PHONY: test test-mocha
test: test-mocha
test-mocha: node_modules
NODE_ENV=$(NODE_ENV) \
NODE_PATH=$(NODE_PATH_TEST) \
$(MOCHA) \
--reporter $(MOCHA_REPORTER) \
$(TESTS)
# CODE COVERAGE #
.PHONY: test-cov test-istanbul-mocha
test-cov: test-istanbul-mocha
test-istanbul-mocha: node_modules
NODE_ENV=$(NODE_ENV) \
NODE_PATH=$(NODE_PATH_TEST) \
$(ISTANBUL) cover \
--dir $(ISTANBUL_OUT) \
--report $(ISTANBUL_REPORT) \
$(_MOCHA) -- \
--reporter $(MOCHA_REPORTER) \
$(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 #
# Installing node_modules:
.PHONY: install
install:
npm install
# Clean node:
.PHONY: clean-node
clean-node:
rm -rf node_modules
# CLEAN #
.PHONY: clean
clean:
rm -rf build