Skip to content

Commit 73364d0

Browse files
committed
build: use nyc for coverage testing
1 parent deef329 commit 73364d0

File tree

6 files changed

+26
-21
lines changed

6 files changed

+26
-21
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
.nyc_output
12
coverage
23
node_modules

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.nyc_output/
12
coverage/
23
node_modules/
34
npm-debug.log

.travis.yml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,27 @@ before_install:
4848
elif [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -lt 10 ]]; then
4949
npm install --save-dev [email protected]
5050
fi
51-
- |
52-
# istanbul for coverage
53-
# - remove for Node.js < 0.10
54-
if [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -eq 0 && "$(cut -d. -f2 <<< "$TRAVIS_NODE_VERSION")" -lt 10 ]]; then
55-
npm rm --silent --save-dev istanbul
56-
fi
5751
- |
5852
# browserify for browser testing
5953
# - install for Node.js > 0.8
6054
if [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -gt 0 || "$(cut -d. -f2 <<< "$TRAVIS_NODE_VERSION")" -gt 8 ]]; then
6155
npm install --silent --save-dev browserify
6256
fi
57+
- |
58+
# nyc for coverage
59+
# - remove for Node.js < 0.10
60+
# - use 10.x for Node.js < 4
61+
# - use 11.x for Node.js < 6
62+
# - use 14.x for Node.js < 8
63+
if [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -eq 0 && "$(cut -d. -f2 <<< "$TRAVIS_NODE_VERSION")" -lt 10 ]]; then
64+
npm rm --save-dev nyc
65+
elif [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -lt 4 ]]; then
66+
npm install --save-dev [email protected]
67+
elif [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -lt 6 ]]; then
68+
npm install --save-dev [email protected]
69+
elif [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -lt 8 ]]; then
70+
npm install --save-dev [email protected]
71+
fi
6372
- |
6473
# eslint for linting
6574
# - remove on Node.js < 8
@@ -79,7 +88,7 @@ before_install:
7988
script:
8089
# Run test script
8190
- |
82-
if npm -ps ls istanbul | grep -q istanbul; then
91+
if npm -ps ls nyc | grep -q nyc; then
8392
npm run test-ci
8493
else
8594
npm test
@@ -92,7 +101,7 @@ script:
92101
after_script:
93102
- |
94103
# Upload coverage to coveralls
95-
if [[ -f ./coverage/lcov.info ]]; then
104+
if [[ -d .nyc_output ]]; then
96105
npm install --save-dev [email protected]
97-
coveralls < ./coverage/lcov.info
106+
nyc report --reporter=text-lcov | coveralls
98107
fi

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ install:
3737
# Remove benchmark dependencies
3838
npm rm --silent --save-dev benchmark beautify-benchmark
3939
# Remove coverage dependency
40-
npm rm --silent --save-dev istanbul
40+
npm rm --silent --save-dev nyc
4141
# Remove lint dependencies
4242
cmd.exe /c "node -pe `"Object.keys(require('./package').devDependencies).join('\n')`"" | `
4343
sls "^eslint(-|$)" | `

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@
2020
"eslint-plugin-node": "9.2.0",
2121
"eslint-plugin-promise": "4.2.1",
2222
"eslint-plugin-standard": "4.0.1",
23-
"istanbul": "0.4.5",
23+
"nyc": "15.1.0",
2424
"mocha": "8.0.1",
25-
"safe-buffer": "5.1.2",
26-
"uid-safe": "2.1.5"
25+
"safe-buffer": "5.1.2"
2726
},
2827
"files": [
2928
"lib/",
@@ -39,7 +38,7 @@
3938
"bench": "node benchmark/index.js",
4039
"lint": "eslint --plugin markdown --ext js,md .",
4140
"test": "mocha --reporter spec --bail test/",
42-
"test-ci": "istanbul cover --print=none node_modules/mocha/bin/_mocha -- --reporter spec test/ && istanbul report lcovonly text-summary",
43-
"test-cov": "istanbul cover --print=none node_modules/mocha/bin/_mocha -- --reporter dot test/ && istanbul report lcov text-summary"
41+
"test-ci": "nyc --reporter=text npm test",
42+
"test-cov": "nyc --reporter=html --reporter=text npm test"
4443
}
4544
}

test/test.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ var path = require('path')
99
var script = path.join(__dirname, 'fixtures', 'script.js')
1010
var spawn = require('child_process').spawn
1111
var strictlib = libs.strict
12-
var uid = require('uid-safe').sync
1312

1413
describe('depd(namespace)', function () {
1514
it('creates deprecated function', function () {
@@ -761,11 +760,7 @@ function captureChildStderr (script, opts, callback) {
761760
var env = { PATH: process.env.PATH }
762761
var exec = process.execPath
763762

764-
var args = process.env.running_under_istanbul
765-
? opts.concat(path.join(__dirname, '..', 'node_modules', 'istanbul', 'lib', 'cli.js'),
766-
'cover', '--dir=./coverage/child-' + uid(8), '--print=none', script)
767-
: opts.concat(script)
768-
763+
var args = opts.concat(script)
769764
var proc = spawn(exec, args, {
770765
env: env
771766
})

0 commit comments

Comments
 (0)