Skip to content

Commit

Permalink
initial issue fix
Browse files Browse the repository at this point in the history
  • Loading branch information
z committed Dec 23, 2017
1 parent 5f9fa20 commit f697c73
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
17 changes: 16 additions & 1 deletion src/contributors/prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 4 additions & 2 deletions src/generate/format-contribution-type.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const _ = require('lodash/fp')

const util = require('../util')

const linkTemplate = _.template(
Expand All @@ -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}`,
)
}

Expand Down

0 comments on commit f697c73

Please sign in to comment.