-
-
Save andrewfinnell/1004022e741c46a762859c3ff6c412d1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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