Passed
Push — master ( bae175...7396a8 )
by Vitor
04:40 queued 01:42
created

cli/export-pdf-resume.js   A

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 25
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 16
mnd 0
bc 0
fnc 1
dl 0
loc 25
rs 10
bpm 0
cpm 1
noi 1
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A export-pdf-resume.js ➔ exportResumeAsPdf 0 16 1
1
/* eslint-disable no-console */
2
import puppeteer from 'puppeteer';
3
import path from 'path';
4
5
const rootDir = process.cwd();
6
const sourceHtmlFile = path.join('public', 'resume', 'index.html');
7
const targetPdf = path.join('static', 'vitor-mello-resume.pdf');
8
9
async function exportResumeAsPdf() {
10
  console.log('Starting PDF export.', '\n');
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
11
  const browser = await puppeteer.launch({ headless: true });
12
  const page = await browser.newPage();
13
14
  console.log(`Opening "/${sourceHtmlFile}"...`);
15
16
  await page.goto(`file://${path.join(rootDir, sourceHtmlFile)}`, { waitUntil: 'networkidle0' });
17
18
  await page.pdf({ format: 'A4', path: targetPdf, margin: { top: 0, right: 0, bottom: 0, left: 0 } });
19
20
  await page.close();
21
  await browser.close();
22
23
  console.log('\n', `✅  All done! PDF exported to "/${targetPdf}".`);
24
}
25
26
exportResumeAsPdf();
27