-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
85 lines (81 loc) · 2.05 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
// TODO: Include packages needed for this application
const inquirer = require("inquirer");
const fs = require("fs");
const path = require("path");
const generateMarkdown = require("./utils/generateMarkdown.js");
// TODO: Create an array of questions for user input
const questions = [
{
type: "input",
name: "github",
message: "What is your GitHub username?",
},
{
type: "input",
name: "email",
message: "What is your email address?",
},
{
type: "input",
name: "projName",
message: "What is your projects name?",
},
{
type: "input",
name: "description",
message: "Please write a short description of your project",
},
{
type: "input",
name: "challenges",
message: "What challenges did you encounter?",
},
{
type: "list",
name: "license",
message: "What kind of license should your project have?",
choices: ["MIT", "APACHE 2.0", "GPLv3", "ISC", "None"],
},
{
type: "input",
name: "installDep",
message: "What command should be run to install dependencies?",
default: "npm i",
},
{
type: "input",
name: "tests",
message: "What command should be run to run tests?",
default: "npm test",
},
{
type: "input",
name: "repoKnow",
message: "What does the user need to know about using this repo?",
},
{
type: "input",
name: "contribute",
message: "What does the user need to know about contributing to this repo?",
},
];
// TODO: Create a function to write README file
function writeToFile(fileName, data) {
fs.writeFileSync(path.join(__dirname, fileName), data, (err) =>
err ? console.log(err) : console.log("Success!")
);
}
// TODO: Create a function to initialize app
function init() {
inquirer
.prompt(questions)
.then((data) => {
//console.log(data);
const fileName = "/ReadMeDEMO.md";
writeToFile(fileName, generateMarkdown({ ...data }));
})
.then(() => console.log("successfully created Readme!"))
.catch((err) => console.error(err));
}
// Function call to initialize app
init();