forked from petitchevalroux/node-semantic-scraper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
82 lines (55 loc) · 1.87 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
.PHONY: install
install: .build/install
.PHONY: tests
tests: .build/tests
.PHONY: beautify
beautify: .build/beautify
.PHONY: lint
lint: .build/lint
.PHONY: coverage
coverage: coverage/lcov.info
.PHONY: report
report: coverage/lcov-report/index.html
open $<
.PHONY: install-git-hook
install-git-hook:
rm -f .git/hooks/pre-commit
ln -s ../../git-precommit-hook.sh .git/hooks/pre-commit
.PHONY: check-coverage
check-coverage: .build/check-coverage
.PHONY: clean
clean:
rm -rf .build node_modules
.build/build: Makefile
mkdir -p .build && touch $@
.build/install: .build/build package.json
npm install && touch $@
TEST_PATH="tests"
TEST_FILES=$(shell test -d $(TEST_PATH) && find $(TEST_PATH) -type f -name "*.js")
SOURCE_PATH="src"
SOURCE_FILES=$(shell test -d $(SOURCE_PATH) && find $(SOURCE_PATH) -type f -name "*.js")
MOCHA=node_modules/.bin/_mocha
$(MOCHA): .build/install
.build/tests: .build/build $(MOCHA) $(TEST_FILES) $(SOURCE_FILES)
test "$(TEST_FILES)" = "" || $(MOCHA) $(TEST_FILES)
touch $@
JSBEAUTIFY=node_modules/.bin/js-beautify
$(JSBEAUTIFY): .build/install
.build/beautify: .build/build $(JSBEAUTIFY) $(TEST_FILES) $(SOURCE_FILES)
$(eval FILES := $(filter-out .build/build $(JSBEAUTIFY), $?))
test "$(FILES)" = "" || $(JSBEAUTIFY) -r $(FILES)
touch $@
ESLINT=node_modules/.bin/eslint
$(ESLINT): .build/install
.build/lint: .build/build $(ESLINT) $(TEST_FILES) $(SOURCE_FILES)
$(eval FILES := $(filter-out .build/build, $(filter-out $(ESLINT), $?)))
test "$(FILES)" = "" || $(ESLINT) $(FILES)
touch $@
ISTANBUL=node_modules/.bin/istanbul
$(ISTANBUL): .build/install
coverage/lcov.info: .build/build $(ISTANBUL) $(TEST_FILES) $(SOURCE_FILES)
test "$(TEST_FILES)" = "" || $(ISTANBUL) cover $(MOCHA) $(TEST_FILES)
coverage/lcov-report/index.html: coverage
.build/check-coverage: .istanbul.yml coverage
test ! -f coverage/lcov.info || $(ISTANBUL) check
touch $@