-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
79 lines (63 loc) · 2.03 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
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
default: help
help:
@echo "$$USAGE"
pkgdir:
@mkdir -p $(PKGDIR)
clean:
@rm -rf $(PKGDIR)
build: pkgdir
@rm -f $(MAXOUT)
@cat vendor/{soak,broadcast}.js > $(MAXOUT)
@echo "$$HEADER" >> $(MAXOUT)
@cat lib/m.js lib/m/{dom,create,remove,sandbox,events,module}.js >> $(MAXOUT)
@echo Created $(MAXOUT)
package: clean build
@`npm bin`/uglifyjs $(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:
@phantomjs test/index.js $(GREP)
serve:
@echo "Tests are available at http://localhost:$(PORT)/test/index.html"
@python -m SimpleHTTPServer $(PORT)
lint:
@`npm bin`/jshint --show-non-errors --config jshint.json lib
ci:
@$(MAKE) test
@$(MAKE) test DOM_LIBRARY=zepto
@$(MAKE) lint
.PHONY: help pkgdir clean build package test serve lint ci