forked from michaelficarra/CoffeeScriptRedux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
65 lines (51 loc) · 1.74 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
default: all
SRC = $(shell find src -name "*.coffee" -type f | sort)
LIB = $(SRC:src/%.coffee=lib/coffee-script/%.js) lib/coffee-script/parser.js
LIBMIN = $(LIB:lib/coffee-script/%.js=lib/coffee-script/%.min.js)
TESTS = $(shell find test -name "*.coffee" -type f | sort)
ROOT = $(shell pwd)
# TODO: use `node_modules/.bin/<binary>`
COFFEE = node_modules/coffee-script/bin/coffee
PEGJS = node_modules/pegjs/bin/pegjs --track-line-and-column --cache
MOCHA = node_modules/mocha/bin/mocha --compilers coffee:. -u tdd
MINIFIER = node_modules/uglify-js/bin/uglifyjs --no-copyright --mangle-toplevel --reserved-names require,module,exports,global,window
all: $(LIB)
build: all
parser: lib/coffee-script/parser.js
minify: $(LIBMIN)
deps:
git submodule update --init
cd $(ROOT)/node_modules/mocha && npm install commander debug diff
cd $(ROOT)/node_modules/pegjs && make build
cd $(ROOT)
# TODO: build-browser
# TODO: test-browser
# TODO: doc
# TODO: bench
lib/coffee-script:
mkdir -p lib/coffee-script/
lib/coffee-script/parser.js: src/grammar.pegjs lib/coffee-script
printf %s "module.exports = " > "$@"
$(PEGJS) < "$<" >> "$@"
lib/coffee-script/%.js: src/%.coffee lib/coffee-script
$(COFFEE) -bsc < "$<" > "$@"
lib/coffee-script/%.min.js: lib/coffee-script/%.js lib/coffee-script
$(MINIFIER) < "$<" > "$@"
.PHONY: test coverage install loc clean
test: $(LIB) $(TESTS)
$(MOCHA) -R spec
coverage: $(LIB)
@which jscoverage || (echo "install node-jscoverage"; exit 1)
rm -rf instrumented
jscoverage -v lib instrumented
$(MOCHA) -R dot
$(MOCHA) $(LIB:lib/%.js=-r instrumented/%) -R html-cov > coverage.html
@xdg-open coverage.html &> /dev/null
install: $(LIB)
npm install -g .
loc:
wc -l src/*
clean:
rm -rf instrumented
rm -f coverage.html
rm -rf lib/*