From 2436f3f71904fb56fb74f27d6d940a17e756fc71 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 21 Apr 2020 21:38:21 -0400 Subject: [PATCH] build: use nyc for code coverage --- .gitignore | 1 + .travis.yml | 21 ++++++++++++--------- package.json | 8 ++++---- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 0fa6951..f15b98e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.nyc_output/ coverage/ node_modules/ npm-debug.log diff --git a/.travis.yml b/.travis.yml index 54dabeb..3e419e0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -70,10 +70,6 @@ before_install: # Configure eslint for linting if node_version_lt '8.0'; then npm_remove_module_re '^eslint(-|$)' fi - - | - # Configure istanbul for coverage - if node_version_lt '0.10'; then npm_remove_module_re '^istanbul$' - fi - | # Configure mocha for testing if node_version_lt '0.8' ; then npm_use_module 'mocha' '1.21.5' @@ -82,6 +78,13 @@ before_install: 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 '0.10'; then npm_remove_module_re '^nyc$' + elif 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 # Update Node.js modules - | # Prune & rebuild node_modules @@ -95,8 +98,8 @@ before_scrpt: npm -s ls ||: script: - | - # Run test script, depending on istanbul install - if npm_module_installed 'istanbul'; then npm run-script test-ci + # Run test script, depending on nyc install + if npm_module_installed 'nyc'; then npm run-script test-ci else npm test fi - | @@ -105,8 +108,8 @@ script: fi after_script: - | - # Upload coverage to coveralls if exists - if [[ -e ./coverage/lcov.info ]]; then + # Upload coverage to coveralls + if [[ -d .nyc_output ]]; then npm install --save-dev coveralls@2 - coveralls < ./coverage/lcov.info + nyc report --reporter=text-lcov | coveralls fi diff --git a/package.json b/package.json index f9f6717..1f342e7 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,8 @@ "benchmark": "2.1.4", "eslint": "6.8.0", "eslint-plugin-markdown": "1.0.2", - "istanbul": "0.4.5", - "mocha": "7.1.1" + "mocha": "7.1.1", + "nyc": "15.0.1" }, "files": [ "HISTORY.md", @@ -33,8 +33,8 @@ "bench": "node benchmark/index.js", "lint": "eslint --plugin markdown --ext js,md .", "test": "mocha --reporter spec --bail --check-leaks --ui qunit test/", - "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks --ui qunit test/", - "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks --ui qunit test/", + "test-ci": "nyc --reporter=text npm test", + "test-cov": "nyc --reporter=html --reporter=text npm test", "version": "node scripts/version-history.js && git add HISTORY.md" } }