Skip to content

Commit

Permalink
♻️ Code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Franck committed Jun 8, 2019
1 parent 912c602 commit 1ae6c40
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 33 deletions.
32 changes: 3 additions & 29 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,7 @@ const boxen = require('boxen')
const { getProjectInfos } = require('./utils')

const { getTemplate, createReadme } = require('./utils')
const {
askProjectName,
askProjectDescription,
askAuhtorName,
askAuthorGithub,
askAuthorTwitter,
askLicenseUrl,
askContributing,
askProjectVersion,
askProjectPrerequisites,
askLicenseName,
askProjectDocumentationUrl
} = require('./questions')
const questionsBuilders = require('./questions')

/**
* Ask user questions and return context to generate a README
Expand All @@ -31,22 +19,8 @@ const askQuestions = async projectInfos => {
projectPrerequisites: undefined
}

const questionFns = [
askProjectName,
askProjectVersion,
askProjectDescription,
askProjectDocumentationUrl,
askAuhtorName,
askAuthorGithub,
askAuthorTwitter,
askProjectPrerequisites,
askLicenseName,
askLicenseUrl,
askContributing
]

for (const questionFn of questionFns) {
const question = questionFn(projectInfos, answersContext)
for (const questionBuilder of Object.values(questionsBuilders)) {
const question = questionBuilder(projectInfos, answersContext)

if (!isNil(question)) {
const currentAnswerContext = await inquirer.prompt([question])
Expand Down
8 changes: 4 additions & 4 deletions src/questions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ const askProjectDocumentationUrl = require('./project-documentation-url')

module.exports = {
askProjectName,
askProjectVersion,
askProjectDescription,
askProjectDocumentationUrl,
askAuhtorName,
askAuthorGithub,
askAuthorTwitter,
askProjectPrerequisites,
askLicenseName,
askLicenseUrl,
askContributing,
askProjectVersion,
askProjectPrerequisites,
askProjectDocumentationUrl
askContributing
}

0 comments on commit 1ae6c40

Please sign in to comment.