-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
59 lines (48 loc) · 1.2 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
/**********************
* README Generator
* Copyright 2022
* Author: Luna Roberge
/**********************/
// #include
const inquirer = require("inquirer");
const fs = require("fs");
const generateReadMe = require("./utils/generate-readme-cli.js");
/** Global constants **/
// Version
const version = "1.0.0";
// Misc functions
function print(c) {
console.log(c);
return 0;
}
// TODO: Create a function to write README file
function writeToFile(fileName, data) {
if (!fileName) {
console.error("ERROR: Invalid filename. Using current date.");
fileName = Date.now();
}
fs.writeFile(fileName, data,
E => {
if (E) {
console.error(E);
}
else {
print(`Successfuly wrote file '${fileName}'.`)
}
}
)
}
function init() {
print("README Generator, v" + version +'\n');
var readMe = {};
inquirer
.prompt(generateReadMe.questions)
.then((answers) => {
readMe = generateReadMe.createReadMe(answers);
readMe.setMarkdown();
var date = new Date();
writeToFile("README_" + date.toISOString() + ".md", readMe.markdown);
});
}
// Function call to initialize app
init();