-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
80 lines (75 loc) · 2.04 KB
/
index.js
File metadata and controls
80 lines (75 loc) · 2.04 KB
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
const inquirer = require("inquirer");
const fs = require("fs");
const generateMd = require("./generateMd");
const questions = [
{
type: "input",
message: "What is your project name?",
name: "title"
},
{
type: "input",
message: "Write a short description of project",
name: "description"
},
{
type: "input",
message: "What command will install dependencies?",
name: "installation",
default: "npm i"
},
{
type: "input",
message: "What does the user need to know about using the repository?",
name: "usage"
},
{
type: "input",
message: "What does the user need to know about contributing to the repository?",
name: "contribute"
},
{
type: "input",
message: "What command should be run to run tests?",
name: "tests",
default: "npm run test"
},
{
type: "confirm",
message: "Include MIT license?",
name: "license"
},
{
type: "input",
message: "What is your GitHub user name?",
name: "username"
},
{
type: "input",
message: "What is your email address?",
name: "email"
},
]
const promptUser = () => {
return inquirer
.prompt(questions);
}
const init = async () => {
try {
console.log("Welcome to ReadMe Generator" + "Please answer these questions:")
const answers = await promptUser();
if (answers.license) {
answers.license = "[!(https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)"
} else {answers.license = ""}
console.log(answers)
const fileContent = generateMd(answers);
fs.writeFile("./output/ReadMe.md", fileContent, (err) => {
if (err)throw err;
});
console.log("ReadMe.md created in output folder.");
} catch (err) {
console.error("Error creating README. File not created.");
console.log(err);
}
}
init();