-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
66 lines (49 loc) · 1.18 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
# -*- globals -*- #
SRC_DIR = src
BUILD_DIR = build
CLEAN += $(BUILD_DIR)/*
SRC = $(SRC_DIR)/p.js
.PHONY: all
all: minify commonjs amd report
# -*- minification -*- #
UGLIFYJS ?= ./node_modules/.bin/uglifyjs
UGLIFY_OPTS += -m -c hoist_vars=true,unsafe=true
UGLY = $(BUILD_DIR)/p.min.js
$(UGLY): $(SRC)
$(UGLIFYJS) $(UGLIFY_OPTS) $< -o $@
%.min.js: %.js
$(UGLIFYJS) $(UGLIFY_OPTS) $< -o $@
minify: $(UGLY)
# special builds
COMMONJS = $(BUILD_DIR)/p.commonjs.js
$(BUILD_DIR)/p.%.js: $(SRC_DIR)/%/pre.js $(SRC) $(SRC_DIR)/%/post.js
mkdir -p $(BUILD_DIR)
cat $^ > $@
.PHONY: commonjs
commonjs: $(COMMONJS)
.PHONY: amd
amd: $(BUILD_DIR)/p.amd.js $(BUILD_DIR)/p.amd.min.js
.PHONY: report
report: $(UGLY)
wc -c $(UGLY)
# -*- testing -*- #
MOCHA ?= ./node_modules/.bin/mocha
TESTS = ./test/*.test.js
.PHONY: test
test: $(COMMONJS)
$(MOCHA) $(TESTS)
# -*- packaging -*- #
VERSION = $(shell node -e 'console.log(require("./package.json").version)')
PACKAGE = pjs-$(VERSION).tgz
CLEAN += pjs-*.tgz
$(PACKAGE): clean commonjs test
npm pack .
.PHONY: package
package: $(PACKAGE)
.PHONY: publish
publish: $(PACKAGE)
npm publish $(PACKAGE)
# -*- cleanup -*- #
.PHONY: clean
clean:
rm -f $(CLEAN)