Skip to content

Commit

Permalink
build: restructure Travis CI build steps
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Aug 1, 2018
1 parent 74e43de commit 6d4a993
Showing 1 changed file with 48 additions and 13 deletions.
61 changes: 48 additions & 13 deletions .travis.yml
Expand Up @@ -20,20 +20,55 @@ 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) -lt 1 || npm install --save-dev browserify@16"
- "test $(echo $TRAVIS_NODE_VERSION | cut -d. -f1) -ge 4 || npm rm --save-dev $(grep -E '\"eslint\\S*\"' package.json | cut -d'\"' -f2)"
- |
# 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
- |
# browserify for browser testing
# - install on Node.js >= 1
if [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -ge 1 ]]; then
npm install --save-dev browserify@16
fi
- |
# eslint for linting
# - remove on Node.js < 4
if [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -lt 4 ]]; then
node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \
grep -E '^eslint(-|$)' | \
xargs npm rm --save-dev
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 [[ -z "$(npm -ps ls istanbul)" ]]; then
npm test
else
npm run-script test-travis
fi
- |
# Run linting, if eslint exists
if [[ -n "$(npm -ps ls 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

0 comments on commit 6d4a993

Please sign in to comment.