-
Notifications
You must be signed in to change notification settings - Fork 12
/
Makefile
62 lines (50 loc) · 1.88 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
default: build
BINDIR = bin
SRCDIR = src
LIBDIR = lib
TESTDIR = test
DISTDIR = dist
SRC = $(shell find "$(SRCDIR)" -name "*.coffee" -type f | sort)
LIB = $(SRC:$(SRCDIR)/%.coffee=$(LIBDIR)/%.js)
TEST = $(shell find "$(TESTDIR)" -name "*.coffee" -type f | sort)
COFFEE=node_modules/.bin/coffee --js
MOCHA=node_modules/.bin/mocha --compilers coffee:coffee-script-redux/register -r coffee-script-redux/register -r test-setup.coffee -u tdd -R dot
CJSIFY=node_modules/.bin/cjsify --minify
all: build test
build: $(LIB)
bundle: $(DISTDIR)/bundle.js
$(LIBDIR)/%.js: $(SRCDIR)/%.coffee
@mkdir -p "$(@D)"
$(COFFEE) <"$<" >"$@"
$(DISTDIR)/bundle.js: $(LIB)
@mkdir -p "$(@D)"
$(CJSIFY) -a /node_modules/escodegen/node_modules/source-map/lib/source-map.js: -x esfuzz $(shell node -pe 'require("./package.json").main') >"$@"
.PHONY: phony-dep release test loc clean
phony-dep:
VERSION = $(shell node -pe 'require("./package.json").version')
release-patch: NEXT_VERSION = $(shell node -pe 'require("semver").inc("$(VERSION)", "patch")')
release-minor: NEXT_VERSION = $(shell node -pe 'require("semver").inc("$(VERSION)", "minor")')
release-major: NEXT_VERSION = $(shell node -pe 'require("semver").inc("$(VERSION)", "major")')
release-patch: release
release-minor: release
release-major: release
release: build test
@printf "Current version is $(VERSION). This will publish version $(NEXT_VERSION). Press [enter] to continue." >&2
@read
node -e '\
var j = require("./package.json");\
j.version = "$(NEXT_VERSION)";\
var s = JSON.stringify(j, null, 2) + "\n";\
require("fs").writeFileSync("./package.json", s);'
git commit package.json -m 'Version $(NEXT_VERSION)'
git tag -a "v$(NEXT_VERSION)" -m "Version $(NEXT_VERSION)"
git push --tags origin HEAD:master
npm publish
test:
$(MOCHA) $(TEST)
$(TESTDIR)/%.coffee: phony-dep
$(MOCHA) "$@"
loc:
@wc -l "$(SRCDIR)"/*
clean:
@rm -rf "$(LIBDIR)" "$(DISTDIR)"