mirror of
https://github.com/all-contributors/cli.git
synced 2025-01-09 13:36:29 +00:00
initial issue fix
This commit is contained in:
parent
5f9fa20346
commit
f697c73c48
2 changed files with 20 additions and 3 deletions
|
@ -68,10 +68,25 @@ function getQuestions(options, username, contributions) {
|
|||
]
|
||||
}
|
||||
|
||||
function getValidUserContributions(options, contributions) {
|
||||
const validContributionTypes = util.contributionTypes(options)
|
||||
const userContributions = contributions && contributions.split(',')
|
||||
|
||||
const validUserContributions = _.filter(
|
||||
userContribution => validContributionTypes[userContribution] !== undefined,
|
||||
)(userContributions)
|
||||
|
||||
if (_.isEmpty(validUserContributions)) {
|
||||
throw new Error('Please specify valid contribution types')
|
||||
}
|
||||
|
||||
return validUserContributions
|
||||
}
|
||||
|
||||
module.exports = function prompt(options, username, contributions) {
|
||||
const defaults = {
|
||||
username,
|
||||
contributions: contributions && contributions.split(','),
|
||||
contributions: getValidUserContributions(options, contributions),
|
||||
}
|
||||
const questions = getQuestions(options, username, contributions)
|
||||
return inquirer.prompt(questions).then(_.assign(defaults))
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
const _ = require('lodash/fp')
|
||||
|
||||
const util = require('../util')
|
||||
|
||||
const linkTemplate = _.template(
|
||||
|
@ -19,8 +20,9 @@ module.exports = function formatContribution(
|
|||
|
||||
if (!type) {
|
||||
throw new Error(
|
||||
`Unknown contribution type ${contribution} for contributor ${contributor.login ||
|
||||
contributor.name}`,
|
||||
`Unknown contribution type ${
|
||||
contribution
|
||||
} for contributor ${contributor.login || contributor.name}`,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue