-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
93 lines (73 loc) · 1.78 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
#
# Binaries.
#
DUO = node_modules/.bin/duo
DUOT = node_modules/.bin/duo-test
ESLINT = node_modules/.bin/eslint
#
# Files.
#
SRCS_DIR = lib
SRCS = $(shell find $(SRCS_DIR) -type f -name "*.js")
TESTS_DIR = test
TESTS = $(shell find $(TESTS_DIR) -type f -name '*.test.js')
#
# Task config.
#
BROWSER ?= chrome
PORT ?= 0
DUOT_ARGS = \
--reporter spec \
--port $(PORT) \
--commands "make build"
#
# Chore tasks.
#
# Install node dependencies.
node_modules: package.json $(wildcard node_modules/*/package.json)
@npm install
# Remove temporary files and build artifacts.
clean:
rm -rf build.js
.PHONY: clean
# Remove temporary files, build artifacts, and vendor dependencies.
distclean: clean
rm -rf components node_modules
.PHONY: distclean
#
# Build tasks.
#
# Build all integrations, tests, and dependencies together for testing.
build.js: node_modules component.json $(SRCS) $(TESTS)
@$(DUO) --stdout --development $(TESTS) > $@
# Build shortcut.
build: build.js
.DEFAULT_GOAL = build
#
# Test tasks.
#
# Lint JavaScript source.
lint: node_modules
@$(ESLINT) $(SRCS) $(TESTS)
.PHONY: lint
# Test locally in PhantomJS.
test-phantomjs: node_modules build.js
@$(DUOT) phantomjs $(TESTS_DIR) args: \
--path node_modules/.bin/phantomjs
.PHONY: test
# Test locally in the browser.
test-browser: node_modules build.js
@$(DUOT) browser --commands "make build" $(TESTS_DIR)
.PHONY: test-browser
# Test in Sauce Labs. Note that you must set the SAUCE_USERNAME and
# SAUCE_ACCESS_KEY environment variables using your Sauce Labs credentials.
test-sauce: node_modules build.js
@$(DUOT) saucelabs $(TESTS_DIR) \
--name analytics.js-integrations \
--browsers $(BROWSER) \
--user $(SAUCE_USERNAME) \
--key $(SAUCE_ACCESS_KEY)
.PHONY: test-sauce
# Test shortcut.
test: lint test-phantomjs
.PHONY: test