initial issue fix

This commit is contained in:
z 2017-12-23 14:10:40 +05:30
parent 5f9fa20346
commit f697c73c48
2 changed files with 20 additions and 3 deletions

View file

@ -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))

View file

@ -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}`,
)
}