diff --git a/.travis.yml b/.travis.yml index 5392cfc..631fdab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,19 +20,50 @@ cache: directories: - node_modules before_install: - # Skip updating shrinkwrap / lock - - "npm config set shrinkwrap false" + # Configure npm + - | + # Skip updating shrinkwrap / lock + npm config set shrinkwrap false # Setup Node.js version-specific dependencies - - "test $TRAVIS_NODE_VERSION != '0.6' || npm rm --save-dev istanbul" - - "test $TRAVIS_NODE_VERSION != '0.8' || npm rm --save-dev istanbul" - - "test $(echo $TRAVIS_NODE_VERSION | cut -d. -f1) -ge 6 || npm rm --save-dev $(grep -E '\"eslint\\S*\"' package.json | cut -d'\"' -f2)" + - | + # eslint for linting + # - remove on Node.js < 6 + if [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -lt 6 ]]; then + node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \ + grep -E '^eslint(-|$)' | \ + xargs npm rm --save-dev + fi + - | + # istanbul for coverage + # - remove on Node.js < 0.10 + if [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -eq 0 && "$(cut -d. -f2 <<< "$TRAVIS_NODE_VERSION")" -lt 10 ]]; then + npm rm --save-dev istanbul + fi # Update Node.js modules - - "test ! -d node_modules || npm prune" - - "test ! -d node_modules || npm rebuild" + - | + # Prune & rebuild node_modules + if [[ -d node_modules ]]; then + npm prune + npm rebuild + fi + script: - # Run test script, depending on istanbul install - - "test ! -z $(npm -ps ls istanbul) || npm test" - - "test -z $(npm -ps ls istanbul) || npm run-script test-travis" - - "test -z $(npm -ps ls eslint ) || npm run-script lint" + - | + # 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: - - "test -e ./coverage/lcov.info && npm install coveralls@2 && cat ./coverage/lcov.info | coveralls" + - | + # Upload coverage to coveralls, if exists + if [[ -f ./coverage/lcov.info ]]; then + npm install --save-dev coveralls@2 + coveralls < ./coverage/lcov.info + fi