-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerateMarkdown.js
95 lines (90 loc) · 1.97 KB
/
generateMarkdown.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
const fs = require("fs");
const names = [
"Installation",
"Usage",
"License",
"Contributors",
"Tests",
"Questions",
];
const writeToFile = (response) => {
fs.writeFile("Generated_README.md", "", (err) => {
if (err) {
console.log(err);
} else {
}
});
fs.appendFileSync(
"Generated_README.md",
"# " +
response.title +
"\n \n" +
"[](https://github.com/ffejcaplan?tab=followers)" +
"\n \n" +
"## " +
"Project Description" +
"\n" +
response.description,
(err) => {
if (err) {
console.log(err);
} else {
}
}
);
if (response.TOC == true) {
fs.appendFileSync(
"Generated_README.md",
"\n \n" + "## Table of Contents" + "\n",
(err) => {
if (err) {
console.log(err);
} else {
}
}
);
names.forEach((content) => {
const contentLC = content.toLowerCase();
fs.appendFileSync(
"Generated_README.md",
"* " + `[${content}]` + `(#${contentLC})` + "\n",
(err) => {
if (err) {
console.log(err);
} else {
}
}
);
});
}
for (i = 0; i < names.length - 1; i++) {
const namely = names[i].toLocaleLowerCase();
fs.appendFileSync(
"Generated_README.md",
"\n \n" + "## " + names[i] + "\n" + response[namely],
(err) => {
if (err) {
console.log(err);
} else {
}
}
);
}
fs.appendFileSync(
"Generated_README.md",
"\n \n" +
"## " +
"Questions" +
"\n" +
`If you have any questions about the repo, open an issue or contact me directly at ${
response.GitHubEmail
} ${"\n"} `,
(err) => {
if (err) {
console.log(err);
} else {
}
}
);
};
module.exports = { writeToFile: writeToFile };