Skip to content

Commit

Permalink
feat(coverage): allow for multiple provider publish
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Jul 8, 2017
1 parent 65843aa commit a323017
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
6 changes: 3 additions & 3 deletions cmds/coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ module.exports = {
describe: 'Upload the results to one of the providers',
default: false
},
provider: {
providers: {
alias: 'p',
type: 'string',
type: 'array',
choices: Object.keys(coverage.providers),
default: 'coveralls'
default: ['codecov']
}
},
handler (argv) {
Expand Down
19 changes: 9 additions & 10 deletions src/coverage/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
'use strict'

const path = require('path')
const _ = require('lodash')
const Listr = require('listr')

const providers = require('./providers')
const testNode = require('../test/node')

function publish (opts) {
const coverFile = path.join(process.cwd(), 'coverage', 'lcov.info')
return providers[opts.publisher](coverFile)
}

function coverage (opts) {
const tasks = new Listr([{
title: 'Generating Coverage Report',
Expand All @@ -19,11 +15,14 @@ function coverage (opts) {
coverage: true
}))
}
}, {
title: `Publish report to ${opts.provider}`,
task: publish,
enabled: (ctx) => ctx.publish
}])
}].concat(Object.keys(providers).map((name) => ({
title: `Publish report to ${name}`,
task: (opts) => {
const coverFile = path.join(process.cwd(), 'coverage', 'lcov.info')
return providers[name](coverFile)
},
enabled: (ctx) => _.includes(ctx.providers, name)
}))))

return tasks.run(opts)
}
Expand Down

0 comments on commit a323017

Please # to comment.