Skip to content

Commit

Permalink
Write function who allow us to parse the choices array who hold infor…
Browse files Browse the repository at this point in the history
…mation about templates and push this informations in an array which will be send in inquirer
  • Loading branch information
luctst committed Jul 31, 2019
1 parent 456e173 commit 6326de2
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,29 @@
const inquirer = require("inquirer");
const figlet = require("figlet");
const fs = require("fs");
const choices = require("./utils/choices.js");

const inquirerChoices = [];

console.log(
figlet.textSync("get-good-readme", {
horizontalLayout: "full"
})
);

console.log("We need you to ask a few questions, it should not be too long. \n");
console.log("We need to ask you a few questions, it should not be too long. \n");

fs.readdirSync(`${__dirname}/template`).forEach(el => {
choices.filter(choice => {
if (choice.templateName === el) {
return inquirerChoices.push({
name: `${choice.name} ${new inquirer.Separator(choice.description)}`,
value: choice.templateName.split(".md")[0]
});
}
return false;
});
});

inquirer
.prompt([
Expand All @@ -34,12 +49,7 @@ inquirer
name: "template",
type: "list",
message: "What kind of README file you want use ? ",
choices: [
{
name: `default ${new inquirer.Separator(" Good for all type of projects.")}`,
value: "default"
}
]
choices: [...inquirerChoices]
}
])
.then(answers => {
Expand Down

0 comments on commit 6326de2

Please sign in to comment.