forked from ageitgey/node-unfluff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
60 lines (48 loc) · 1.76 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
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 test-setup.coffee -u tdd -R dot
CJSIFY=node_modules/.bin/cjsify --minify
SEMVER=node_modules/.bin/semver
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) -x ProjectName $(shell node -pe 'require("./package.json").main') >"$@"
.PHONY: phony-dep all build release-patch release-minor release-major test loc clean
phony-dep:
VERSION = $(shell node -pe 'require("./package.json").version')
release-patch: NEXT_VERSION = $(shell $(SEMVER) -i patch $(VERSION))
release-minor: NEXT_VERSION = $(shell $(SEMVER) -i minor $(VERSION))
release-major: NEXT_VERSION = $(shell $(SEMVER) -i major $(VERSION))
release-patch release-minor release-major: build test
@printf "Current version is $(VERSION). This will publish version $(NEXT_VERSION). Press [enter] to continue." >&2
@read nothing
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)"