Skip to content

Commit ce921e2

Browse files
committed
build: restructure Travis CI build steps
1 parent d2d00b9 commit ce921e2

File tree

1 file changed

+43
-15
lines changed

1 file changed

+43
-15
lines changed

.travis.yml

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,50 @@ cache:
2121
directories:
2222
- node_modules
2323
before_install:
24-
# Skip updating shrinkwrap / lock
25-
- "npm config set shrinkwrap false"
26-
# SSL certificate not in older Node.js versions
27-
- "test $TRAVIS_NODE_VERSION != '0.6' || npm config set strict-ssl false"
28-
- "test $TRAVIS_NODE_VERSION != '0.8' || npm config set strict-ssl false"
24+
# Configure npm
25+
- |
26+
# Skip updating shrinkwrap / lock
27+
npm config set shrinkwrap false
2928
# Setup Node.js version-specific dependencies
30-
- "test $TRAVIS_NODE_VERSION != '0.6' || npm rm --save-dev istanbul"
31-
- "test $TRAVIS_NODE_VERSION != '0.8' || npm rm --save-dev istanbul"
32-
- "test $(echo $TRAVIS_NODE_VERSION | cut -d. -f1) -ge 6 || npm rm --save-dev $(grep -E '\"eslint\\S*\"' package.json | cut -d'\"' -f2)"
29+
- |
30+
# eslint for linting
31+
# - remove on Node.js < 6
32+
if [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -lt 6 ]]; then
33+
node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \
34+
grep -E '^eslint(-|$)' | \
35+
xargs npm rm --save-dev
36+
fi
37+
- |
38+
# istanbul for coverage
39+
# - remove on Node.js < 0.10
40+
if [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -eq 0 && "$(cut -d. -f2 <<< "$TRAVIS_NODE_VERSION")" -lt 10 ]]; then
41+
npm rm --save-dev istanbul
42+
fi
3343
# Update Node.js modules
34-
- "test ! -d node_modules || npm prune"
35-
- "test ! -d node_modules || npm rebuild"
44+
- |
45+
# Prune & rebuild node_modules
46+
if [[ -d node_modules ]]; then
47+
npm prune
48+
npm rebuild
49+
fi
50+
3651
script:
37-
# Run test script, depending on istanbul install
38-
- "test ! -z $(npm -ps ls istanbul) || npm test"
39-
- "test -z $(npm -ps ls istanbul) || npm run-script test-travis"
40-
- "test -z $(npm -ps ls eslint ) || npm run-script lint"
52+
- |
53+
# Run test script, depending on istanbul install
54+
if npm -ps ls istanbul | grep -q istanbul; then
55+
npm run-script test-travis
56+
else
57+
npm test
58+
fi
59+
- |
60+
# Run linting, depending on eslint install
61+
if npm -ps ls eslint | grep -q eslint; then
62+
npm run-script lint
63+
fi
4164
after_script:
42-
- "test -e ./coverage/lcov.info && npm install coveralls@2 && cat ./coverage/lcov.info | coveralls"
65+
- |
66+
# Upload coverage to coveralls, if exists
67+
if [[ -f ./coverage/lcov.info ]]; then
68+
npm install --save-dev coveralls@2
69+
coveralls < ./coverage/lcov.info
70+
fi

0 commit comments

Comments
 (0)