Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
67 lines (49 sloc) 1.22 KB
# -*- globals -*- #
SRC_DIR = src
BUILD_DIR = build
CLEAN += $(BUILD_DIR)/*
SRC = $(SRC_DIR)/p.js
.PHONY: all
all: minify commonjs amd report
# -*- minification -*- #
UGLIFYJS ?= uglifyjs
UGLIFY_OPTS += --lift-vars --unsafe
UGLY = $(BUILD_DIR)/p.min.js
$(UGLY): $(SRC)
$(UGLIFYJS) $< > $@
$(BUILD_DIR)/%.min.js: $(BUILD_DIR)/%.js
$(UGLIFYJS) $< > $@
minify: $(UGLY)
# special builds
COMMONJS = $(BUILD_DIR)/p.commonjs.js
$(BUILD_DIR)/p.%.js: $(SRC) $(SRC_DIR)/p.%.post.js
cat $^ > $@
.PHONY: commonjs
commonjs: $(COMMONJS) $(BUILD_DIR)/p.commonjs.min.js
.PHONY: amd
amd: $(BUILD_DIR)/p.amd.js $(BUILD_DIR)/p.amd.min.js
.PHONY: report
report: $(UGLY)
wc -c $(UGLY)
# -*- testing -*- #
MOCHA ?= mocha
TESTS = ./test/*.test.js
.PHONY: test
test: $(COMMONJS)
$(MOCHA) $(TESTS)
# -*- packaging -*- #
# XXX this is kind of awful, but hey, it keeps the version info in the right place.
VERSION = $(shell node -e 'console.log(JSON.parse(require("fs").readFileSync(__dirname + "/package.json")).version)')
PACKAGE = pjs-$(VERSION).tgz
CLEAN += $(PACKAGE)
$(PACKAGE): test
npm pack .
.PHONY: package
package: $(PACKAGE)
.PHONY: publish
publish: $(PACKAGE)
npm publish $(PACKAGE)
# -*- cleanup -*- #
.PHONY: clean
clean:
rm -f $(CLEAN)