@@ -19,18 +19,49 @@ cache:
1919 directories :
2020 - node_modules
2121before_install :
22- # Skip updating shrinkwrap / lock
23- - " npm config set shrinkwrap false"
22+ # Configure npm
23+ - |
24+ # Skip updating shrinkwrap / lock
25+ npm config set shrinkwrap false
2426 # 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+ - |
28+ # eslint for linting
29+ # - remove on Node.js < 6
30+ if [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -lt 6 ]]; then
31+ node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \
32+ grep -E '^eslint(-|$)' | \
33+ xargs npm rm --save-dev
34+ fi
35+ - |
36+ # istanbul for coverage
37+ # - remove for Node.js < 0.10
38+ if [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -eq 0 && "$(cut -d. -f2 <<< "$TRAVIS_NODE_VERSION")" -lt 10 ]]; then
39+ npm rm --silent --save-dev istanbul
40+ fi
2741 # Update Node.js modules
28- - " test ! -d node_modules || npm prune"
29- - " test ! -d node_modules || npm rebuild"
42+ - |
43+ # Prune and rebuild node_modules
44+ if [[ -d node_modules ]]; then
45+ npm prune
46+ npm rebuild
47+ fi
3048script :
31- # Run test script, depending on istanbul install
32- - " test ! -z $(npm -ps ls istanbul) || npm test"
33- - " test -z $(npm -ps ls istanbul) || npm run-script test-ci"
34- - " test -z $(npm -ps ls eslint ) || npm run-script lint"
49+ # Run test script
50+ - |
51+ if npm -ps ls istanbul | grep -q istanbul; then
52+ npm run test-ci
53+ else
54+ npm test
55+ fi
56+ # Run linting
57+ - |
58+ if npm -ps ls eslint | grep -q eslint; then
59+ npm run lint
60+ fi
3561after_script :
36- - " test -e ./coverage/lcov.info && npm install coveralls@2.11.2 && cat ./coverage/lcov.info | coveralls"
62+ - |
63+ # Upload coverage to coveralls
64+ if [[ -f ./coverage/lcov.info ]]; then
65+ npm install --save-dev coveralls@2.13.3
66+ coveralls < ./coverage/lcov.info
67+ fi
0 commit comments