Skip to content

Commit

Permalink
feat(coverage): add codecov to coverage providers
Browse files Browse the repository at this point in the history
Coveralls is the default, you can select codecov in your package.json
file by adding `--provider=codecov` to the `coverage-publish` script.
  • Loading branch information
Kubuxu authored and dignifiedquire committed Jan 26, 2017
1 parent c3f0b82 commit 8f06c99
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
38 changes: 30 additions & 8 deletions bin/coverage
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,45 @@

const gulp = require('gulp')
const coveralls = require('coveralls')
const codecov = require('codecov/lib/codecov').upload
const fs = require('fs')
const path = require('path')
const args = require('args-parser')(process.argv)

require('../src/gulp-log')(gulp)
require('../gulp')(gulp, ['coverage'])

if (args.publish) {
const handlers = {
coveralls: (coverFile) => {
const input = fs.readFileSync(coverFile)
coveralls.handleInput(input.toString(), (err) => {
if (err) {
throw err
}

console.log('Finished uploading coveralls report')
// ./node_modules/.bin/coveralls --verbose < coverage/lcov.info
const input = fs.readFileSync(path.join(process.cwd(), 'coverage', 'lcov.info'))
coveralls.handleInput(input.toString(), (err) => {
if (err) {
throw err
}
})
},
codecov: (coverFile) => {
codecov({options: {
file: coverFile,
disable: 'search'
}})
}
}

if (args.publish) {
const provider = args.provider || 'coveralls'
const handler = handlers[provider]
if (handler === undefined) {
const msg = 'no such coverage report provider: ' + provider
console.log(msg)
throw new Error(msg)
}

console.log('Finished uploading coveralls report')
})
const coverFile = path.join(process.cwd(), 'coverage', 'lcov.info')
handler(coverFile)
} else {
gulp.start('coverage')
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"browserify-zlib-next": "^1.0.0",
"chalk": "^1.1.3",
"clean-documentation-theme": "^0.4.2",
"codecov": "^1.0.1",
"conventional-github-releaser": "^1.1.3",
"coveralls": "^2.11.15",
"detect-node": "^2.0.3",
Expand Down Expand Up @@ -99,4 +100,4 @@
"greenkeeperio-bot <support@greenkeeper.io>",
"npmcdn-to-unpkg-bot <npmcdn-to-unpkg-bot@users.noreply.github.com>"
]
}
}

0 comments on commit 8f06c99

Please sign in to comment.