cli/export-pdf-resume.js   A
last analyzed

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 24
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

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

1 Function

Rating   Name   Duplication   Size   Complexity  
A export-pdf-resume.js ➔ exportResumeAsPdf 0 16 1
1
import path from 'path';
2
import puppeteer from 'puppeteer';
3
4
const sourceUrl = 'http://localhost:9000/resume';
5
const targetPdf = path.join('public', 'vitor-mello-resume.pdf');
6
7
async function exportResumeAsPdf() {
8
  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...
9
  const browser = await puppeteer.launch({ headless: true });
10
  const page = await browser.newPage();
11
12
  console.log(`Opening "${sourceUrl}"...`);
13
14
  await page.goto(sourceUrl, { waitUntil: 'networkidle0' });
15
16
  await page.pdf({ format: 'A4', path: targetPdf, margin: { top: 0, right: 0, bottom: 0, left: 0 } });
17
18
  await page.close();
19
  await browser.close();
20
21
  console.log('\n', `✅  All done! PDF exported to "/${targetPdf}".`);
22
}
23
24
exportResumeAsPdf();
25