Skip to content

Commit bcfff94

Browse files
committed
build: restructure Travis CI build steps
1 parent 53c23a9 commit bcfff94

File tree

1 file changed

+43
-10
lines changed

1 file changed

+43
-10
lines changed

.travis.yml

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +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 4 || npm rm --save-dev $(grep -E '\"eslint\\S*\"' package.json | cut -d'\"' -f2)"
26+
- |
27+
# eslint for linting
28+
# - remove on Node.js < 4
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"
49+
- |
50+
# Run test script, depending on istanbul install
51+
if [[ -n "$(npm -ps ls 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 [[ -n "$(npm -ps ls eslint)" ]]; then
59+
npm run-script lint
60+
fi
3361
after_script:
34-
- "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)