-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
106 lines (102 loc) · 2.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// 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",
message: "Please provide a title for your application (*required):",
name: "title",
validate: (input) => {
if(input) {
return true;
} else {
console.log("Please enter a title");
return false;
}
}
},
{
type: "input",
message: "Please provide a description for your application (*required):",
name: "description",
validate: (input) => {
if(input) {
return true;
} else {
console.log("Please enter a description");
return false;
}
}
},
{
type: "input",
message: "Please provide any installation instructions for your application:",
name: "installation",
default: "N/A",
},
{
type: "input",
message: "Please provide any information that will help others use your application:",
name: "usage",
default: "N/A",
},
{
type: "list",
message: "Please select one below. If not interested in licensing, select 'none':",
name: "license",
choices: ["MIT", "GPL v3", "Apache", "none"],
},
{
type: "input",
message: "Please provide guidelines for how to contribute to your application:",
name: "contribution",
default: "N/A",
},
{
type: "input",
message: "Please provide any testing instructions to assist users:",
name: "testing",
default: "N/A",
},
{
type: "input",
message: "Please provide your GitHub username (*required):",
name: "github",
validate: (input) => {
if(input) {
return true;
} else {
console.log("Please enter your Github profile name");
return false;
}
}
},
{
type: "input",
message: "Please provide a preferred email address (*required):",
name: "email",
validate: (input) => {
if(input) {
return true;
} else {
console.log("Please enter your email address");
return false;
}
}
},
];
// TODO: Create a function to write README file
function writeToFile(fileName, data) {
fs.writeFile(fileName, generateMarkdown(data), (err) =>
err ? console.error(err) : console.log("Success!"))
};
// TODO: Create a function to initialize app
function init() {
inquirer
.prompt(questions)
.then((response) => writeToFile("Sample_README.md", response));
};
// Function call to initialize app
init();