-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
86 lines (78 loc) · 2.07 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// TODO: Include packages needed for this application
const fs = require("fs");
const inquirer = require('inquirer');
const generateMarkdown = require("./utils/generateMarkdown");
// TODO: Create an array of questions for user input
const questions = [
{
type: 'input',
name: 'title',
message: 'What is the title of your project?',
validate: titleInput => {
if (titleInput) {
return true;
} else {
console.log('Please enter a title!');
return false;
}
}
},
{
type: 'input',
name: 'description',
message: 'Explain what your project does.',
},
{
type: 'input',
name: 'install',
message: 'How do I install your project!',
},
{
type: 'input',
name: 'usage',
message: 'In what ways is your project used?',
},
{
type: "list",
message: "What license does your project use?",
name: "license",
choices: ["mit", "agpl-3.0", "mpl-2.0", "apache-2.0",],
},
{
type: 'confirm',
name: 'contribute',
message: 'Would you like other developers to contribute to your project? ',
default: false,
},
{
type: 'input',
name: 'test',
message: 'How would I test your application?'
},
{
type: 'input',
name: 'username',
message: 'What is your GitHub username?'
},
{
type: 'input',
name: 'email',
message: 'What is your email address?'
},
]
// TODO: Create a function to write README file
function writeToFile(fileName, data) {
fs.writeFile(fileName, data, err => {
if (err) throw err;
console.log('Your ReadMe is complete, please view it under ReadMeGnrt!')
})
}
// TODO: Create a function to initialize app
function init() {
inquirer.prompt(questions)
.then(function (data) {
writeToFile("ReadMeGnrt.md", generateMarkdown(data));
})
}
// Function call to initialize app
init();