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 Sep 26, 2018
1 parent f3c56d1 commit 4e9123c
Showing 1 changed file with 40 additions and 18 deletions.
58 changes: 40 additions & 18 deletions .travis.yml
Expand Up @@ -20,25 +20,47 @@ 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
# Remove all non-test dependencies
- npm rm --save-dev benchmark
- npm rm --save-dev beautify-benchmark

- |
# Remove build dependencies
npm rm --save-dev benchmark
npm rm --save-dev beautify-benchmark
# 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)"

# Update Node.js modules
- "test ! -d node_modules || npm prune"
- "test ! -d node_modules || npm rebuild"
- |
# 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 --silent --save-dev istanbul
fi
- |
# 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
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 [[ -n "$(npm -ps ls istanbul)" ]]; then
npm run-script test-travis
else
npm test
fi
- |
# Run linting, depending on eslint install
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 4e9123c

Please sign in to comment.