forked from readmill/m.js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
92 lines (72 loc) · 2.32 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
json = $(shell node -p -e 'require("./package.json").$(1)')
NAME = $(call json,name)
VERSION = $(call json,version)
LICENSE = $(call json,license)
HOMEPAGE = $(call json,homepage)
COPYRIGHT = 2012-$(shell TZ=UTC date +%Y)
define HEADER
/* $(NAME).js - v$(VERSION)
* Copyright $(COPYRIGHT), Readmill Network Ltd
* Released under the $(LICENSE) license
* More Information: $(HOMEPAGE)
*/
endef
export HEADER
define USAGE
Usage instructions:
make serve runs a development server on port 8000
make serve port=[port] runs a development server on the port specified
make test runs the test suite using phantomjs
make test grep=[filter] runs the tests matching filter
make clean removes the pkg directory
make build creates a development build
make package creates a production (minified) build
make help displays this message
endef
export USAGE
PKGDIR = pkg
MAXOUT = $(PKGDIR)/m.js
MINOUT = $(PKGDIR)/m.min.js
port ?= 8000
npmbin := $(shell npm bin)
runner := $(npmbin)/mocha-phantomjs
uglify := $(npmbin)/uglifyjs
jshint := $(npmbin)/jshint
default: help
help:
@echo "$$USAGE"
pkgdir:
@mkdir -p $(PKGDIR)
clean:
@rm -rf $(PKGDIR)
build: pkgdir
@rm -f $(MAXOUT)
@echo "$$HEADER" >> $(MAXOUT)
@./script/build >> $(MAXOUT)
@echo Created $(MAXOUT)
package: clean build
@$(uglify) $(MAXOUT) --mangle --comments '/Copyright \d{4}/' --output $(MINOUT)
@cat $(MINOUT) | gzip -c > $(MINOUT).gz
@echo "Built files..."
@ls -lahS pkg/*.{js,gz} | awk '{printf "%s\t%s\n", $$9, $$5}'
@rm $(MINOUT).gz
@zip -qj $(PKGDIR)/m.zip $(MAXOUT) $(MINOUT) LICENSE
@echo "Created $(PKGDIR)/m.zip"
test: $(runner)
@COLUMNS=$$COLUMNS $(runner) --reporter=dot "test/index.html?grep=$(grep)#dom=$(DOM_LIBRARY)"
serve:
@echo "Tests are available at http://localhost:$(port)/test/index.html"
@python -m SimpleHTTPServer $(port)
lint: $(jshint)
@$(jshint) --config=jshint.json lib && echo 'No lint errors found'
ci:
@echo 'Running unit tests against jQuery...'
@$(MAKE) test
@echo 'Running unit tests against Zepto...'
@$(MAKE) test DOM_LIBRARY=zepto
@echo 'Linting JavaScript files...'
@$(MAKE) lint
$(runner) $(uglify) $(jshint): $(npmbin)
$(npmbin):
@npm install
.PHONY: help pkgdir clean build package test serve lint ci