-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerationMarkdown.js
90 lines (82 loc) · 2.52 KB
/
generationMarkdown.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
// packages needed for this application
const fs = require("fs");
const inquirer = require("inquirer");
const index = require("./index.js");
// function that returns a license badge based on which license is passed in
// If there is no license, it returns an empty string
function renderLicenseBadge(license) {
let badge = "";
if (license === "MIT") {
badge =
"![GitHub license](https://img.shields.io/github/license/Naereen/StrapDown.js.svg)";
} else if (license === "Apache 2.0") {
badge =
"![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)";
} else if (license === "GPL v3.0") {
badge =
"![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)";
} else {
badge = "";
}
return badge;
}
// function that returns the license link
// If there is no license, it returns an empty string
function renderLicenseLink(license) {
let licenseLink = "";
if (license === "MIT") {
licenseLink = "https://choosealicense.com/licenses/mit/";
} else if (license === "Apache 2.0") {
licenseLink = "http://www.apache.org/licenses/LICENSE-2.0";
} else if (license === "GPL v3.0") {
licenseLink = "https://www.gnu.org/licenses";
} else {
licenseLink = "";
}
return licenseLink;
}
// function that returns the license section of README
// If there is no license, it returns an empty string
function renderLicenseSection(license) {
let licenseSection = "";
if (license === "None") {
licenseSection = "";
} else {
licenseSection = `License: ${license} `;
}
return licenseSection;
}
// function to generate markdown for the README.md
function generateMarkdown(answer) {
return `
# ${answer.title}
## ${renderLicenseSection(answer.license)} ${renderLicenseBadge(
answer.license
)}
### ${renderLicenseLink(answer.license)}
## Table of Contents:
### * [Installation](#installation)
### * [Usage](#usage)
### * [License](#license)
### * [Contributors](#contributors)
### * [Tests](#tests)
### * [Questions](#questions)
## Installation:
### You must install the following for this app to function:
### ${answer.installation}
## Usage :
### ${answer.usage}
## Contributors:
### ${answer.contributions}
## Tests:
### Run the following commands in your terminal to test this app:
### ${answer.tests}
## Questions:
### If you have any questions, you may contact me at either
### Github: https://github.com/${answer.askMe}
### or
### Email: ${answer.email}
`;
}
// exports
module.exports = generateMarkdown;