-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
94 lines (69 loc) · 3.18 KB
/
index.js
File metadata and controls
94 lines (69 loc) · 3.18 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
const inquirer = require("inquirer");
const fs = require('fs')
// array of questions for user
const questions = ['what is the title of your project?', 'What is the description of the project?', 'What license would you like for your application?', 'what is your github username?', 'what is your email address?'
];
const cc = '[](http://creativecommons.org/publicdomain/zero/1.0/)'
const mit = '[](https://opensource.org/licenses/MIT)'
const apache = '[](https://opensource.org/licenses/Apache-2.0)'
const gnu = '[](https://www.gnu.org/licenses/gpl-3.0)'
// function to write README file
function writeToFile(fileName, data, badgeLink) {
const inputs = [`${data.title}`, `${data.description}`, `${data.license}`, `${data.github}`, `${data.email}`]
const filename = `${data.title.toLowerCase().split(' ').join('')}.MD`;
fs.writeFile(filename, badgeLink + '\n\n## Description' +
'\n\n'+ inputs[1] + '\n\n# Table of Contents \n\n' + '1. [Description](#Description)\n 2. [Questions](#Questions?) \n\n 3. [Installation](#Installation) \n\n 4. [Usage](#Usage) \n\n 5. [Contributing](#Contributing) \n\n6. [License](#License) \n\n 7. [Tests](#Tests)', (err) =>{
if (err) throw (err)
}
)
fs.appendFile(filename,
'\n\n' + '## Installation\n\n\n' + '## Usage\n\n\n' + '## Contributing\n\n\n'+
'## Questions?\n\n\n' +
'Contact me here:\n\n' +
'[GitHub Profile](https://www.github.com/' + inputs[3] + ')' +
'\n\n[Email](mailto:'+inputs[4] +')' + '\n\n Reach out to me at either of the links above if you have any questions regarding the project or if you want to become a collaborator.\n\n' + '## License\n' + inputs[2] + '\n\n## Tests',
(err) => console.log(err))
};
// function to initialize program
function init() {
inquirer
.prompt ([
{
type: 'input',
message:questions[0],
name: 'title'
} ,
{
type: 'input',
message: questions[1],
name: 'description'
} ,
{
type: 'list',
message: questions[2],
choices: ['Apache', 'CC', 'MIT', 'GNU'],
name: 'license'
} ,
{
type: 'input',
message:questions[3],
name: 'github'
} ,
{
type: 'input',
message:questions[4],
name: 'email'
} ,
])
.then((data) => {
if (`${data.license}` =='CC') {
badgeLink = cc
} else if (`${data.license}` == 'Apache') {
badgeLink = apache
} else if (`${data.license}` == 'GNU') {
badgeLink = gnu
} else badgeLink = mit
writeToFile(`${data.title.toLowerCase().split(' ').join('')}.MD`, data, badgeLink)
})}
// function call to initialize program
init()