Prechádzať zdrojové kódy

Reformat using prettier

theenglishway (time) 2 rokov pred
rodič
commit
c73a38140b
1 zmenil súbory, kde vykonal 34 pridanie a 34 odobranie
  1. 34 34
      to_pdf.js

+ 34 - 34
to_pdf.js

@@ -1,54 +1,54 @@
 #!/usr/bin/node
 
-const fs = require('fs')
-const path = require('path')
-const yaml = require('yaml')
+const fs = require("fs");
+const path = require("path");
+const yaml = require("yaml");
 
-const puppeteer = require('puppeteer')
-const pug = require('pug')
+const puppeteer = require("puppeteer");
+const pug = require("pug");
 
 const cv = yaml.parse(fs.readFileSync("./cv.yaml", { encoding: "utf8" }));
 
 function changeExt(filePath, new_) {
-    parsed = path.parse(filePath)
-    return path.join(parsed.dir, `${path.basename(parsed.name)}.${new_}`)
+  parsed = path.parse(filePath);
+  return path.join(parsed.dir, `${path.basename(parsed.name)}.${new_}`);
 }
 
 function createHtml(pug_file) {
-    const rendered = pug.renderFile(pug_file, cv)
-    const html_path = changeExt(pug_file, "html")
-
-    fs.writeFile(html_path, rendered, (err) => {
-        if (err) throw err;
-    })
-    console.log(`Wrote HTML file to ${html_path}`)
-    return html_path
+  const rendered = pug.renderFile(pug_file, cv);
+  const html_path = changeExt(pug_file, "html");
+
+  fs.writeFile(html_path, rendered, (err) => {
+    if (err) throw err;
+  });
+  console.log(`Wrote HTML file to ${html_path}`);
+  return html_path;
 }
 
 async function printPDF(url) {
-    const browser = await puppeteer.launch({ headless: "new" });
-    const page = await browser.newPage();
-    await page.goto(url, { waitUntil: 'networkidle0' });
-    const pdf = await page.pdf({ format: 'A4' });
+  const browser = await puppeteer.launch({ headless: "new" });
+  const page = await browser.newPage();
+  await page.goto(url, { waitUntil: "networkidle0" });
+  const pdf = await page.pdf({ format: "A4" });
 
-    await browser.close();
-    return pdf
+  await browser.close();
+  return pdf;
 }
 
 function exportToPdf(htmlFile) {
-    url = `file://${path.resolve(htmlFile)}`
-    pdf_path = changeExt(htmlFile, "pdf")
-
-    printPDF(url).then((pdf) => {
-        fs.writeFile(pdf_path, pdf, (err) => {
-            if (err) throw err;
-        })
-        console.log(`Wrote PDF file to ${pdf_path}`)
-    })
+  url = `file://${path.resolve(htmlFile)}`;
+  pdf_path = changeExt(htmlFile, "pdf");
+
+  printPDF(url).then((pdf) => {
+    fs.writeFile(pdf_path, pdf, (err) => {
+      if (err) throw err;
+    });
+    console.log(`Wrote PDF file to ${pdf_path}`);
+  });
 }
 
-local_pug_path = './resume.pug'
-local_pdf_path = changeExt(local_pug_path, "pdf")
+local_pug_path = "./resume.pug";
+local_pdf_path = changeExt(local_pug_path, "pdf");
 
-local_html_path = createHtml(local_pug_path)
-exportToPdf(local_html_path)
+local_html_path = createHtml(local_pug_path);
+exportToPdf(local_html_path);