forked from cristobal-io/mortgage-calculator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
101 lines (80 loc) · 2.99 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
93
94
95
96
97
98
99
100
101
SHELL = /bin/bash
MAKEFLAGS += --no-print-directory --silent
export PATH := ./node_modules/.bin:$(PATH):./bin
DIST_DIR= $(wildcard lib/*.js)
LINT_DIR = $(wildcard *.js test/*.js lib/*.js test/**/*.json spikes/*)
BROWSERIFY_DEPS = $(wildcard lib/*.js test/*.test.js node_modules/*/package.json )
setup:
npm install
# the default will run lint jscs and test
default: ci
path:
echo $$PATH
# generate distribution file with browserify and uglifyjs
dist: dist/mortgage-calculator.min.js
dist/mortgage-calculator.browserify.js: clean
mkdir -p dist
echo "generating browserify file from lib/ ..."
browserify $(DIST_DIR) --standalone mortgageCalculator > $@
echo "browserify lib file generated"
dist/mortgage-calculator.min.js: dist/mortgage-calculator.browserify.js
echo "generating min file with uglify..."
uglifyjs dist/mortgage-calculator.browserify.js > $@
echo " uglify file generated."
# generates the test bundle file for mocha test.html
test/bundle:
mkdir -p test/bundle
test/bundle/test_bundle.js: test/bundle $(BROWSERIFY_DEPS)
browserify test/*.js > $@
echo "test_bundle.js file generated."
test-browser: test/bundle/test_bundle.js
open test/test.html
testem:
testem
# run test with dependencies lint and jscs
test: setup lint style
echo "Test started"
mocha test/
# For coveralls integration on Travis-ci
test-coveralls:
test -d node_modules/nyc/ || npm install nyc
nyc mocha && nyc report --reporter=text-lcov | coveralls
# Dev mode for continuous testing
dev:
mocha --watch test
lint:
echo "Linting started..."
jshint $(LINT_DIR)
echo "Linting finished without errors"
echo
style:
echo "Checking style..."
jscs $(LINT_DIR)
echo
# Continuous Integration Test Runner
ci: lint style test
echo "1. 'make dist'"
echo "2. Make sure 'git status' is clean."
echo "3. 'git checkout -b (release-x.x.x || hotfix-x.x.x) master"
echo "4. 'git merge development --no-ff --log'"
echo "5. 'Make release'"
release: lint style test
echo "1. 'git checkout master'"
echo "2. 'git merge (release-x.x.x || hotfix-x.x.x) --no-ff --log'"
echo "3. 'release-it'"
echo "4. 'git checkout development'"
echo "5. 'git merge (release-x.x.x || hotfix-x.x.x) --no-ff --log'"
echo "6. 'git tag tag-feature-wxyz feature-wxyz'"
echo "6. 'git branch -d (release-x.x.x || hotfix-x.x.x)'"
test-coverage-report:
echo "Generating coverage report, please stand by"
test -d node_modules/nyc/ || npm install nyc
nyc mocha && nyc report --reporter=html
clean:
test -d node_modules/nyc/ && rm -r node_modules/nyc* && echo "nyc module removed" || echo "no nyc module found"
test -d coverage/ && rm -r coverage* && echo "coverage folder removed" || echo "no coverage folder found"
test -d .nyc_output/ && rm -r .nyc_output* && echo "nyc output files removed" || echo "no nyc output files found"
test -d test/bundle/ && rm -r test/bundle && echo "test_bundle.js file removed" || echo "no test_bundle file found"
test -d dist/ && rm -r dist/ && echo "dist folder removed" || echo "no dist folder found"
echo "finished."
.PHONY: test ci dist