-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
93 lines (74 loc) · 2.42 KB
/
Makefile
File metadata and controls
93 lines (74 loc) · 2.42 KB
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
VERSION_REGEX = [0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*[^\" ]*
VERSION := $(shell npm ls | grep "swig@" | grep -Eo "${VERSION_REGEX}" -m 1)
TMP = 'tmp'
BIN = node_modules/.bin
PWD = $(shell pwd | sed -e 's/[\/&]/\\&/g')
all:
@echo "Installing packages"
@npm install --depth=100 --loglevel=error
@npm link &>/dev/null
@cp scripts/githooks/* .git/hooks/
@chmod -R +x .git/hooks/
.INTERMEDIATE version: \
browser/comments.js
version:
@sed -i.bak 's/exports\.version = "${VERSION_REGEX}"/exports.version = "${VERSION}"/' lib/swig.js
@rm lib/swig.js.bak
browser/comments.js: FORCE
@sed -i.bak 's/v${VERSION_REGEX}/v${VERSION}/' $@
@rm $@.bak
.SECONDARY dist/swig.js: \
browser/comments.js
.SECONDARY dist/swig.min.js: \
dist/swig.js
.INTERMEDIATE browser/test/tests.js: \
tests/comments.test.js \
tests/filters.test.js \
tests/tags.test.js \
tests/variables.test.js \
tests/tags/autoescape.test.js \
tests/tags/else.test.js \
tests/tags/filter.test.js \
tests/tags/for.test.js \
tests/tags/if.test.js \
tests/tags/macro.test.js \
tests/tags/raw.test.js \
tests/tags/set.test.js \
tests/tags/spaceless.test.js \
tests/basic.test.js
clean: FORCE
@rm -rf dist
@rm -rf ${TMP}
build: clean dist dist/swig.min.js
@echo "Built to ./dist/"
dist:
@mkdir -p $@
dist/swig.js:
@echo "Building $@..."
@cat $^ > $@
@${BIN}/esbuild browser/index.js --bundle --format=iife \
--alias:fs=./browser/stubs/fs.js --alias:path=path-browserify >> $@
dist/swig.min.js:
@echo "Building $@..."
@${BIN}/terser $^ --comments -c -m --source-map "url=swig.js.map" -o $@
browser/test/tests.js:
@echo "Building $@..."
@cat $^ > tests/browser.js
@perl -pi -e 's/\.\.\/\.\.\/lib/\.\.\/lib/g' tests/browser.js
@${BIN}/esbuild tests/browser.js --bundle --format=iife \
--alias:fs=./browser/stubs/fs.js --alias:path=path-browserify > $@
@rm tests/browser.js
tests := $(shell find ./tests -name '*.test.js' ! -path "*node_modules/*")
reporter = dot
opts =
test:
@node --require ./tests/lib/mocha-compat.js --test-reporter=${reporter} ${opts} --test ${tests}
files := $(shell find . -name '*.js' ! -path "./node_modules/*" ! -path "./dist/*" ! -path "./browser*" ! -path "./docs*" ! -path "./tmp*")
lint:
@${BIN}/eslint ${files}
coverage:
@node --require ./tests/lib/mocha-compat.js --test --experimental-test-coverage --test-coverage-include='lib/**' --test-coverage-lines=95 ${opts} ${tests}
FORCE:
.PHONY: all version \
build \
test lint coverage