Skip to content
Permalink
master
Go to file
 
 
Cannot retrieve contributors at this time
100 lines (100 sloc) 2.62 KB
language: node_js
node_js:
- "0.10"
- "0.12"
- "1.8"
- "2.5"
- "3.3"
- "4.9"
- "5.12"
- "6.17"
- "7.10"
- "8.17"
- "9.11"
- "10.19"
- "11.15"
- "12.16"
- "13.12"
cache:
directories:
- node_modules
before_install:
- |
# Setup utility functions
function node_version_lt () {
[[ "$(v "$TRAVIS_NODE_VERSION")" -lt "$(v "${1}")" ]]
}
function npm_remove_module_re () {
node -e '
fs = require("fs");
p = JSON.parse(fs.readFileSync("package.json", "utf8"));
r = RegExp(process.argv[1]);
for (k in p.devDependencies) {
if (r.test(k)) delete p.devDependencies[k];
}
fs.writeFileSync("package.json", JSON.stringify(p, null, 2) + "\n");
' "$@"
}
function npm_use_module () {
node -e '
fs = require("fs");
p = JSON.parse(fs.readFileSync("package.json", "utf8"));
p.devDependencies[process.argv[1]] = process.argv[2];
fs.writeFileSync("package.json", JSON.stringify(p, null, 2) + "\n");
' "$@"
}
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
- |
# Configure eslint for linting
if node_version_lt '8.0'; then npm_remove_module_re '^eslint(-|$)'
fi
- |
# Configure mocha for testing
if node_version_lt '4.0'; then npm_use_module 'mocha' '3.5.3'
elif node_version_lt '6.0'; then npm_use_module 'mocha' '5.2.0'
elif node_version_lt '8.0'; then npm_use_module 'mocha' '6.2.2'
fi
- |
# Configure nyc for testing
if node_version_lt '4.0'; then npm_use_module 'nyc' '10.3.2'
elif node_version_lt '6.0'; then npm_use_module 'nyc' '11.9.0'
elif node_version_lt '8.0'; then npm_use_module 'nyc' '14.1.1'
fi
- |
# Configure supertest for http calls
if node_version_lt '4.0'; then npm_use_module 'supertest' '2.0.0'
elif node_version_lt '6.0'; then npm_use_module 'supertest' '3.4.2'
fi
# Update Node.js modules
- |
# Prune & rebuild node_modules
if [[ -d node_modules ]]; then
npm prune
npm rebuild
fi
before_script:
- |
# Contents of node_modules
npm -s ls ||:
script:
- |
# Run test script
npm run-script test-travis
- |
# Run linting, depending on eslint install
if npm_module_installed 'eslint'; then npm run-script lint
fi
after_script:
- |
# Upload coverage to coveralls
npm install coveralls@2
nyc report --reporter=text-lcov | coveralls
You can’t perform that action at this time.