forked from buremba/rakam-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
99 lines (75 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
SRC = $(wildcard src/*.js)
SNIPPET = src/rakam-snippet.js
TESTS = $(wildcard test/*.js)
BINS = node_modules/.bin
DUO = $(BINS)/duo
MINIFY = $(BINS)/uglifyjs
JSHINT = $(BINS)/jshint
BUILD_DIR = build
PROJECT = rakam
OUT = $(PROJECT).js
SNIPPET_OUT = $(PROJECT)-snippet.min.js
SEGMENT_SNIPPET_OUT = $(PROJECT)-segment-snippet.min.js
MIN_OUT = $(PROJECT).min.js
MOCHA = $(BINS)/mocha-phantomjs
#
# Default target.
#
default: test
#
# Clean.
#
clean:
@-rm -rf components
@-rm -f rakam.js rakam.min.js
@-rm -rf node_modules npm-debug.log
#
# Test.
#
test: build test/browser/index.html
@$(MOCHA) test/browser/index.html
@$(MOCHA) test/browser/snippet.html
#
# Target for `node_modules` folder.
#
node_modules: package.json
@npm install
#
# Target for updating version.
version: component.json package.json src/version.js
node scripts/version
#
# Target for updating readme.
README.md: $(SNIPPET_OUT) version
node scripts/readme
#
# Target for `rakam.js` file.
#
$(OUT): node_modules $(SRC) version
@$(JSHINT) --verbose $(SRC)
@$(DUO) --standalone rakam src/index.js > $(OUT)
@$(MINIFY) $(OUT) --output $(MIN_OUT)
#
# Target for minified `rakam-snippet.js` file.
#
$(SNIPPET_OUT): $(SRC) $(SNIPPET) version
@$(JSHINT) --verbose $(SNIPPET)
@$(MINIFY) $(SNIPPET) -m -b max-line-len=80,beautify=false | awk 'NF' > $(SNIPPET_OUT)
$(SEGMENT_SNIPPET_OUT): $(SRC) $(SNIPPET) version
@grep -Ev "\ba?s\b" $(SNIPPET) | $(MINIFY) -m -b max-line-len=80,beautify=false - \
| awk 'NF' > $(SEGMENT_SNIPPET_OUT)
#
# Target for `tests-build.js` file.
#
build: $(TESTS) $(OUT) $(SNIPPET_OUT) $(SEGMENT_SNIPPET_OUT) README.md
@-mkdir -p build
@$(DUO) --development test/tests.js > build/tests.js
@$(DUO) --development test/snippet-tests.js > build/snippet-tests.js
#
# Target for release.
#
release: $(OUT) $(SNIPPET_OUT) README.md
@-mkdir -p dist
node scripts/release
.PHONY: clean
.PHONY: test