forked from rowanmanning/joblint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.node
115 lines (80 loc) · 2.37 KB
/
Makefile.node
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
#
# Node.js Makefile
# ================
#
# Do not update this file manually – it's maintained separately on GitHub:
# https://github.com/rowanmanning/makefiles/blob/master/Makefile.node
#
# To update to the latest version, run `make update-makefile`.
#
# Meta tasks
# ----------
.PHONY: test
# Useful variables
# ----------------
NPM_BIN = ./node_modules/.bin
export PATH := $(NPM_BIN):$(PATH)
export EXPECTED_COVERAGE := 90
export INTEGRATION_TIMEOUT := 5000
export INTEGRATION_SLOW := 4000
# Output helpers
# --------------
TASK_DONE = echo "✓ $@ done"
# Group tasks
# -----------
all: install ci
ci: verify test
# Install tasks
# -------------
clean:
@git clean -fxd
@$(TASK_DONE)
install: node_modules
@$(TASK_DONE)
node_modules: package.json
@npm prune --production=false
@npm install
@$(TASK_DONE)
# Verify tasks
# ------------
verify: verify-javascript verify-dust verify-spaces
@$(TASK_DONE)
verify-javascript: verify-eslint verify-jshint verify-jscs
@$(TASK_DONE)
verify-dust:
@if [ -e .dustmiterc ]; then dustmite --path ./view && $(TASK_DONE); fi
verify-eslint:
@if [ -e .eslintrc ]; then eslint . && $(TASK_DONE); fi
verify-jshint:
@if [ -e .jshintrc ]; then jshint . && $(TASK_DONE); fi
verify-jscs:
@if [ -e .jscsrc ]; then jscs . && $(TASK_DONE); fi
verify-spaces:
@if [ -e .editorconfig ] && [ -x $(NPM_BIN)/lintspaces ]; then \
git ls-files | xargs lintspaces -e .editorconfig && $(TASK_DONE); \
fi
verify-coverage:
@if [ -d coverage/lcov-report ] && [ -x $(NPM_BIN)/istanbul ]; then \
istanbul check-coverage --statement $(EXPECTED_COVERAGE) --branch $(EXPECTED_COVERAGE) --function $(EXPECTED_COVERAGE) && $(TASK_DONE); \
fi
# Test tasks
# ----------
test: test-unit-coverage verify-coverage test-integration
@$(TASK_DONE)
test-unit:
@if [ -d test/unit ]; then mocha test/unit --recursive && $(TASK_DONE); fi
test-unit-coverage:
@if [ -d test/unit ]; then \
if [ -x $(NPM_BIN)/istanbul ]; then \
istanbul cover $(NPM_BIN)/_mocha -- test/unit --recursive && $(TASK_DONE); \
else \
make test-unit; \
fi \
fi
test-integration:
@if [ -d test/integration ]; then mocha test/integration --timeout $(INTEGRATION_TIMEOUT) --slow $(INTEGRATION_SLOW) && $(TASK_DONE); fi
# Tooling tasks
# -------------
update-makefile:
@curl -s https://raw.githubusercontent.com/rowanmanning/makefiles/master/Makefile.node > Makefile.node
@$(TASK_DONE)