-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
53 lines (40 loc) · 982 Bytes
/
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
NAME = adobe-font-metrics
UMD_NAME = AdobeFontMetrics
all: lint build test
build: $(NAME).js
# Generate a compressed UMD module from ESM source
$(NAME).js: $(NAME).mjs
npx rollup \
--format umd \
--sourcemap $@.map \
--name $(UMD_NAME) \
--input $? \
--file $@
node -e '\
const fs = require("fs"); \
const map = JSON.parse(fs.readFileSync("$@.map", "utf8")); \
delete map.sourcesContent; \
fs.writeFileSync("$@.map", JSON.stringify(map));'
npx terser \
--keep-classnames \
--mangle \
--compress \
--source-map "content=$@.map,url=$(@F).map" \
--output $@ $@
# Wipe generated build targets
clean:
rm -f $(NAME).js*
rm -f *.zip *.tar *.tgz *.log
# Wipe downloaded files *and* generated artefacts
clobber: clean
rm -rf test/corpus
rm -rf node_modules
.PHONY: clean clobber
# Check source for style and syntax errors
lint:
npx eslint $(NAME).mjs test/*.js
.PHONY: lint
# Run unit-tests
test: build
npx mocha test/*-spec.js
.PHONY: test