-
Notifications
You must be signed in to change notification settings - Fork 126
/
Copy pathMakefile
91 lines (73 loc) · 2.06 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
#
# Binaries.
#
DUO = node_modules/.bin/duo
DUOT = node_modules/.bin/duo-test
ESLINT = node_modules/.bin/eslint
#
# Files.
#
SRCS_DIR = lib
SRCS = index.js $(wildcard $(SRCS_DIR)/*/index.js)
TESTS_DIR = test
TESTS = $(wildcard $(SRCS_DIR)/*/test.js)
#
# Task config.
#
BROWSER ?= chrome
INTEGRATION ?= *
#
# 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 integrations.js test/tests.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 test/tests.js integrations.js $(SRCS)
@$(DUO) --development test/index.js > $@
.DEFAULT_GOAL = build.js
# Build a list of all current integrations and the path to their index.js.
integrations.js: node_modules $(SRCS)
@node bin/integrations
# Build a list of all current integration tests and the path to their test.js.
test/tests.js: node_modules $(TESTS)
@node bin/tests
.PHONY: test/tests.js
#
# Test tasks.
#
# Lint JavaScript source.
lint: node_modules
@$(ESLINT) $(SRCS) $(TESTS)
.PHONY: lint
# Test locally in PhantomJS.
test: node_modules lint build.js test/tests.js
@$(DUOT) phantomjs $(TESTS_DIR) args: \
--setting local-to-remote-url-access=true \
--setting web-security=false \
--path node_modules/.bin/phantomjs
.PHONY: test
# Test locally in the browser.
test-browser: node_modules lint build.js test/tests.js
@$(DUOT) browser --commands "make build.js" $(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 lint build.js test/tests.js
@$(DUOT) saucelabs $(TESTS_DIR) \
--name analytics.js-integrations \
--browser $(BROWSER) \
--user $(SAUCE_USERNAME) \
--key $(SAUCE_ACCESS_KEY)
.PHONY: test-sauce