Skip to content

Commit

Permalink
build: make Travis CI version compare readable
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Feb 18, 2019
1 parent 2961089 commit b5e47da
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions .travis.yml
Expand Up @@ -21,33 +21,39 @@ cache:
directories:
- node_modules
before_install:
- |
function v () {
tr '.' '\n' <<< "${1}" \
| awk '{ printf "%03d", $0 }' \
| sed 's/^0*//'
}
# Configure npm
- |
# Skip updating shrinkwrap / lock
npm config set shrinkwrap false
# Setup Node.js version-specific dependencies
- |
# mocha for testing
# - use 1.x for Node.js < 0.8
# - use 2.x for Node.js < 0.10
# - use 3.x for Node.js < 6
if [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -eq 0 && "$(cut -d. -f2 <<< "$TRAVIS_NODE_VERSION")" -lt 8 ]]; then
if [[ "$(v "$TRAVIS_NODE_VERSION")" -lt "$(v '0.8')" ]]; then
# - use 1.x for Node.js < 0.8
npm install --save-dev mocha@1.21.5
elif [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -eq 0 && "$(cut -d. -f2 <<< "$TRAVIS_NODE_VERSION")" -lt 10 ]]; then
elif [[ "$(v "$TRAVIS_NODE_VERSION")" -lt "$(v '0.10')" ]]; then
# - use 2.x for Node.js < 0.10
npm install --save-dev mocha@2.5.3
elif [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -lt 6 ]]; then
elif [[ "$(v "$TRAVIS_NODE_VERSION")" -lt "$(v '6.0')" ]]; then
# - use 3.x for Node.js < 6
npm install --save-dev mocha@3.5.3
fi
- |
# nyc for coverage
# - remove on Node.js < 6
if [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -lt 6 ]]; then
if [[ "$(v "$TRAVIS_NODE_VERSION")" -lt "$(v '6.0')" ]]; then
# - remove on Node.js < 6
npm rm --save-dev nyc
fi
- |
# eslint for linting
# - remove on Node.js < 6
if [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -lt 6 ]]; then
if [[ "$(v "$TRAVIS_NODE_VERSION")" -lt "$(v '6.0')" ]]; then
# - remove on Node.js < 6
node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \
grep -E '^eslint(-|$)' | \
xargs npm rm --save-dev
Expand Down

0 comments on commit b5e47da

Please sign in to comment.