forked from expressjs/session
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
92 lines (91 loc) · 2.25 KB
/
.travis.yml
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
language: node_js
node_js:
- "0.8"
- "0.10"
- "0.12"
- "1.8"
- "2.5"
- "3.3"
- "4.9"
- "5.12"
- "6.16"
- "7.10"
- "8.15"
- "9.11"
- "10.15"
- "11.9"
sudo: false
cache:
directories:
- node_modules
before_install:
- |
function v () {
tr '.' '\n' <<< "${1}" \
| awk '{ printf "%03d", $0 }' \
| sed 's/^0*//'
}
# Configure npm
- |
# Skip updating shrinkwrap / lock
npm config set shrinkwrap false
# Setup Node.js version-specific dependencies
- |
# eslint for linting
if [[ "$(v "$TRAVIS_NODE_VERSION")" -lt "$(v '4.0')" ]]; then
# - remove on Node.js < 4
node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \
grep -E '^eslint(-|$)' | \
xargs npm rm --save-dev
fi
- |
# istanbul for coverage
if [[ "$(v "$TRAVIS_NODE_VERSION")" -lt "$(v '0.10')" ]]; then
# - remove on Node.js < 0.10
npm rm --save-dev istanbul
fi
- |
# mocha for testing
if [[ "$(v "$TRAVIS_NODE_VERSION")" -lt "$(v '0.10')" ]]; then
# - use 2.x for Node.js < 0.10
npm install --save-dev [email protected]
elif [[ "$(v "$TRAVIS_NODE_VERSION")" -lt "$(v '6.0')" ]]; then
# - use 3.x for Node.js < 6
npm install --save-dev [email protected]
fi
- |
# supertest for http calls
if [[ "$(v "$TRAVIS_NODE_VERSION")" -lt "$(v '0.10')" ]]; then
# - use 1.1.0 for Node.js < 0.10
npm install --save-dev [email protected]
elif [[ "$(v "$TRAVIS_NODE_VERSION")" -lt "$(v '4.0')" ]]; then
# - use 2.0.0 for Node.js < 4
npm install --save-dev [email protected]
fi
# Update Node.js modules
- |
# Prune & rebuild node_modules
if [[ -d node_modules ]]; then
npm prune
npm rebuild
fi
script:
- |
# Run test script, depending on istanbul install
if npm -ps ls istanbul | grep -q istanbul; then
npm run-script test-travis
else
npm test
fi
- |
# Run linting, depending on eslint install
if npm -ps ls eslint | grep -q eslint; then
npm run-script lint
fi
after_script:
- |
# Upload coverage to coveralls, if exists
if [[ -f ./coverage/lcov.info ]]; then
npm install --save-dev coveralls@2
coveralls < ./coverage/lcov.info
fi