-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
78 lines (75 loc) · 1.95 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
// TODO: Include packages needed for this application
const inquirer = require('inquirer')
const fs = require('fs')
const generateMarkdown = require('./utils/generateMarkdown')
// TODO: Create an array of questions for user input
const questions = [
{
type: "input",
message: "What is the title of your project?",
name: "title"
},
{
type: "input",
message: "What is a brife description of your project?",
name: "description"
},
{
type: "input",
message: "How do you install?",
name: "installation",
default: "npm i"
},
{
type: "input",
message: "How do you use this repository?",
name: "usage"
},
{
type: "input",
message: "How should someone contribute to this repository?",
name: "contribute"
},
{
type: "input",
message: "What command should be run to run tests?",
name: "tests",
default: "npm run test"
},
{
type: "list",
message: "What Licenses do your application use?",
name: "license",
choices: [
"Apache 2.0",
"GNU v3",
"MIT",
"BSD 3-Clause",
"Mozilla Public License 2.0",
"Unlicense",
]
},
{
type: "input",
message: "What is your GitHub user name?",
name: "username"
},
{
type: "input",
message: "What is your email address?",
name: "email"
},
]
// generates a markdown file
function writeToFile(fileName, data) {
const markdownStr = generateMarkdown(data)
fs.writeFile(`${fileName}.md`, markdownStr, (err) =>
err ? console.log(err) : console.log(`Success you've made a ${fileName}.md!`))
}
// Runs Inquirer
function init() {
inquirer.prompt(questions)
.then((answers) => writeToFile(answers.title, answers))
}
// Initialize the init function
init();