-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
32 lines (25 loc) · 855 Bytes
/
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
import fs from "fs/promises";
import path from 'path'
import inquirer from "inquirer";
import { questions } from "./utils/questions.js";
import { generateMarkdown } from "./utils/generateMarkdown.js";
// Function to write README file
const writeToFile = (fileName, data) => {
const filePath = path.resolve("./generated-readme", fileName); // Edit file path here
fs.writeFile(filePath, data, err => {
if (err) throw err;
});
}
// Function to initialize program
const init = async () => {
try {
const answers = await inquirer.prompt(questions);
const markdownContent = generateMarkdown(answers);
writeToFile("README.md", markdownContent); // Edit file name here
console.log("Successfully generated!");
} catch (error) {
console.error("Error occurred:", error);
}
}
// Calling init to start the application
init();