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) { module.exports = function prompt(options, username, contributions) {
const defaults = { const defaults = {
username, username,
contributions: contributions && contributions.split(','), contributions: getValidUserContributions(options, contributions),
} }
const questions = getQuestions(options, username, contributions) const questions = getQuestions(options, username, contributions)
return inquirer.prompt(questions).then(_.assign(defaults)) return inquirer.prompt(questions).then(_.assign(defaults))

View file

@ -1,4 +1,5 @@
const _ = require('lodash/fp') const _ = require('lodash/fp')
const util = require('../util') const util = require('../util')
const linkTemplate = _.template( const linkTemplate = _.template(
@ -19,8 +20,9 @@ module.exports = function formatContribution(
if (!type) { if (!type) {
throw new Error( throw new Error(
`Unknown contribution type ${contribution} for contributor ${contributor.login || `Unknown contribution type ${
contributor.name}`, contribution
} for contributor ${contributor.login || contributor.name}`,
) )
} }