-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
101 lines (70 loc) · 1.8 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
#
# Directories
#
ROOT := $(shell pwd)
NODE_MODULES := $(ROOT)/node_modules
NODE_BIN := $(NODE_MODULES)/.bin
#
# Tools and binaries
#
ESLINT := $(NODE_BIN)/eslint
JSCS := $(NODE_BIN)/jscs
MOCHA := $(NODE_BIN)/mocha
_MOCHA := $(NODE_BIN)/_mocha
ISTANBUL := $(NODE_BIN)/istanbul
COVERALLS := $(NODE_BIN)/coveralls
NPM := npm
#
# Files
#
GIT_HOOK_SRC = '../../tools/githooks/preush'
GIT_HOOK_DEST = '.git/hooks/preush'
LIB_FILES := $(ROOT)/lib
TEST_FILES := $(ROOT)/test
COVERAGE_FILES := $(ROOT)/coverage
LCOV := $(ROOT)/coverage/lcov.info
# src is everything except node_modules and the example dir
SRCS := $(shell find $(LIB_FILES) $(TEST_FILES) -name '*.js' -type f \
-not \( -path "./node_modules/*" -prune \) \
-not \( -path "./example/*" -prune \))
#
# Targets
#
.PHONY: all
all: clean node_modules lint codestyle test
node_modules: package.json
$(NPM) install
@touch $(NODE_MODULES)
.PHONY: githooks
githooks:
@ln -s $(GIT_HOOK_SRC) $(GIT_HOOK_DEST)
.PHONY: lint
lint: node_modules $(ESLINT) $(SRCS)
$(ESLINT) $(SRCS)
.PHONY: codestyle
codestyle: node_modules $(JSCS) $(SRCS)
$(JSCS) $(SRCS)
.PHONY: codestyle-fix
codestyle-fix: node_modules $(JSCS) $(SRCS)
$(JSCS) $(SRCS) --fix
.PHONY: prepush
prepush: node_modules lint codestyle test
.PHONY: test
test: node_modules $(MOCHA) $(SRCS)
$(MOCHA) -R spec
.PHONY: coverage
coverage: node_modules $(ISTANBUL) $(SRCS)
$(ISTANBUL) cover $(_MOCHA) --report lcovonly -- -R spec
.PHONY: report-coverage
report-coverage: coverage
@cat $(LCOV) | $(COVERALLS)
.PHONY: clean-coverage
clean-coverage:
@rm -rf $(COVERAGE_FILES)
.PHONY: clean
clean: clean-coverage
@rm -rf $(NODE_MODULES)
#
## Debug -- print out a a variable via `make print-FOO`
#
print-% : ; @echo $* = $($*)