Last active
April 21, 2018 00:28
-
-
Save harrietty/e698a28541af59299a876c27da0361b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const inquirer = require('inquirer'); | |
const fs = require('fs'); | |
const CHOICES = fs.readdirSync(`${__dirname}/templates`); | |
const QUESTIONS = [ | |
{ | |
name: 'project-choice', | |
type: 'list', | |
message: 'What project template would you like to generate?', | |
choices: CHOICES | |
}, | |
{ | |
name: 'project-name', | |
type: 'input', | |
message: 'Project name:', | |
validate: function (input) { | |
if (/^([A-Za-z\-\_\d])+$/.test(input)) return true; | |
else return 'Project name may only include letters, numbers, underscores and hashes.'; | |
} | |
} | |
]; | |
inquirer.prompt(QUESTIONS) | |
.then(answers => { | |
console.log(answers); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment