Skip to content

Commit 9d22a1e

Browse files
committed
build: restructure Travis CI build steps
1 parent af83c57 commit 9d22a1e

File tree

1 file changed

+43
-11
lines changed

1 file changed

+43
-11
lines changed

.travis.yml

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

0 commit comments

Comments
 (0)