@@ -18,20 +18,49 @@ cache:
18
18
directories :
19
19
- node_modules
20
20
before_install :
21
- # Skip updating shrinkwrap / lock
22
- - " npm config set shrinkwrap false"
23
-
21
+ # Configure npm
22
+ - |
23
+ # Skip updating shrinkwrap / lock
24
+ npm config set shrinkwrap false
24
25
# Setup Node.js version-specific dependencies
25
- - " test $TRAVIS_NODE_VERSION != '0.8' || npm rm --save-dev istanbul"
26
- - " test $(echo $TRAVIS_NODE_VERSION | cut -d. -f1) -ge 6 || npm rm --save-dev $(grep -E '\" eslint\\ S*\" ' package.json | cut -d'\" ' -f2)"
27
-
26
+ - |
27
+ # istanbul for coverage
28
+ # - remove on Node.js < 0.10
29
+ if [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -eq 0 && "$(cut -d. -f2 <<< "$TRAVIS_NODE_VERSION")" -lt 10 ]]; then
30
+ npm rm --silent --save-dev istanbul
31
+ fi
32
+ - |
33
+ # eslint for linting
34
+ # - remove on Node.js < 6
35
+ if [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -lt 6 ]]; then
36
+ node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \
37
+ grep -E '^eslint(-|$)' | \
38
+ xargs npm rm --save-dev
39
+ fi
28
40
# Update Node.js modules
29
- - " test ! -d node_modules || npm prune"
30
- - " test ! -d node_modules || npm rebuild"
41
+ - |
42
+ # Prune and rebuild node_modules
43
+ if [[ -d node_modules ]]; then
44
+ npm prune
45
+ npm rebuild
46
+ fi
31
47
script :
32
- # Run test script, depending on istanbul install
33
- - " test ! -z $(npm -ps ls istanbul) || npm test"
34
- - " test -z $(npm -ps ls istanbul) || npm run-script test-travis"
35
- - " test -z $(npm -ps ls eslint ) || npm run-script lint"
48
+ - |
49
+ # Run test script, depending on istanbul install
50
+ if npm -ps ls istanbul | grep -q istanbul; then
51
+ npm run-script test-travis
52
+ else
53
+ npm test
54
+ fi
55
+ - |
56
+ # Run linting, depending on eslint install
57
+ if npm -ps ls eslint | grep -q eslint; then
58
+ npm run-script lint
59
+ fi
36
60
after_script :
37
- - " test -e ./coverage/lcov.info && npm install coveralls@2 && cat ./coverage/lcov.info | coveralls"
61
+ - |
62
+ # Upload coverage to coveralls if exists
63
+ if [[ -f ./coverage/lcov.info ]]; then
64
+ npm install --save-dev coveralls@2
65
+ coveralls < ./coverage/lcov.info
66
+ fi
0 commit comments