diff --git a/index.ts b/index.ts index 27ea32f..90e0350 100644 --- a/index.ts +++ b/index.ts @@ -1,10 +1,25 @@ import fs from "node:fs"; +import path from "node:path"; import { mdToPdf } from "md-to-pdf"; +const markdownFilePath = "./resume.md"; +const outputFilePath = "output/art_rosnovsky_software_engineer.pdf"; + (async () => { - const pdf = await mdToPdf({ path: "./resume.md" }).catch(console.error); + if (!fs.existsSync(markdownFilePath)) { + console.error(`File ${markdownFilePath} does not exist.`); + throw new Error(`File ${markdownFilePath} does not exist.`); + } + + try { + const pdf = await mdToPdf({ path: markdownFilePath }); - if (pdf) { - fs.writeFileSync("output/art_rosnovsky_software_engineer.pdf", pdf.content); + if (pdf) { + fs.writeFileSync(path.resolve(__dirname, outputFilePath), pdf.content); + console.log(`PDF has been written to ${outputFilePath}`); + } + } catch (error: any) { + console.error(`Error occurred: ${error.message}`); + throw new Error(error.message); } })(); diff --git a/package.json b/package.json index a902b99..40f26bb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "resume-manager", - "version": "1.0.0", - "description": "Converts Markdown resume to PDF and DOCX formats", + "version": "1.0.1", + "description": "Converts Markdown resume to PDF format.", "main": "dist/index.js", "scripts": { "build": "ts-node index.ts"