-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMakefile
92 lines (65 loc) · 2.4 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
BIN = $(shell npm bin)
MOCHA_CMD = $(BIN)/mocha
ISTANBUL_CMD = node --harmony node_modules/istanbul/lib/cli.js cover
ESLINT_CMD = $(BIN)/eslint --quiet
SRC_JS = $(shell find src -name "*.js")
LIB_JS = $(patsubst src/%.js,lib/%.js,$(SRC_JS))
TEST_JS = $(shell find tests -name "*-test.js")
BABEL_ARGS = --stage 0 --source-maps
MOCHA_ARGS = --harmony --require co-mocha tests/spec.js --compilers js:babel-core/register -R nyan $(TEST_JS) --timeout 500000
MOCHA_ARGS_SPEC = --harmony --require co-mocha tests/spec.js --compilers js:babel-core/register -R spec $(TEST_JS) --timeout 500000
ISTANBUL_ARGS = node_modules/mocha/bin/_mocha -- --timeout 500000 --harmony --require co-mocha tests/spec.js --compilers js:babel-core/register -R spec $(TEST_JS)
TRAVIS_ARGS = node_modules/mocha/bin/_mocha -- --timeout 500000 --harmony --require co-mocha tests/spec.js --compilers js:babel-core/register --report lcovonly -R spec $(TEST_JS)
build: js webpack
clean:
rm -rf public/assets/
rm -rf lib/
clean-db:
rm -rf storage/*.sqlite
rm -rf storage/leveldb/*
clean-stats:
rm -rf storage/webpack-stats.json
storage:
mkdir -p storage
mkdir -p uploads
# Test
test: lint storage
@NODE_ENV=test $(MOCHA_CMD) $(MOCHA_ARGS)
test-spec:
@NODE_ENV=test $(MOCHA_CMD) $(MOCHA_ARGS_SPEC)
test-debug:
@NODE_ENV=debug $(MOCHA_CMD) $(MOCHA_ARGS_SPEC)
test-cov:
@NODE_ENV=test $(ISTANBUL_CMD) $(ISTANBUL_ARGS)
test-ci: storage
@NODE_ENV=test $(ISTANBUL_CMD) $(TRAVIS_ARGS)
lint:
$(ESLINT_CMD) $(SRC_JS) $(TEST_JS)
# Build application quickly
# Faster on first build, but not after that
fast-build: storage fast-js build
# Watch for changes
watch:
@NODE_ENV=development $(MAKE) -j5 storage dev-server
debug:
@NODE_ENV=debug $(MAKE) -j5 node-debug dev-debug
node-debug:
node-inspector --no-preload
# Transpile JavaScript using Babel
js: $(LIB_JS)
$(LIB_JS): lib/%.js: src/%.js
mkdir -p $(dir $@)
babel $< -o $@ $(BABEL_ARGS)
fast-js:
babel src -d lib $(BABEL_ARGS)
watch-js:
babel src -d lib $(BABEL_ARGS) -w
dev-server: $(SRC_JS)
nodemon --ignore ./node_modules/ --harmony ./src/server
dev-debug:
node --harmony --debug ./src/server
webpack: public/assets
public/assets: $(SRC_JS)
@NODE_ENV=production webpack --production --progress --profile --colors --stats --config webpack/server.js
analyze:
@NODE_ENV=production webpack --production --progress --profile --colors --stats --json --config webpack/server.js | analyze-bundle-size