Passed
Pull Request — master (#5)
by Vitor
04:56 queued 02:21
created

bin/compile-pdf-resume.js   A

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 16
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 compile-pdf-resume.js ➔ exportResumeAsPdf 0 17 1
1
// this script assumes you have puppeteer installed, but its not in the list of dependencies
2
// so you have to install it globally with `npm i -g puppeteer` and link it with `npm link puppeteer`
3
const puppeteer = require('puppeteer');
4
const path = require('path');
5
6
async function exportResumeAsPdf(targetFile) {
7
  console.log('Starting PDF export.');
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...
8
  console.log('Opening Puppeteer');
9
  const browser = await puppeteer.launch({ headless: true });
10
  const page = await browser.newPage();
11
12
  await page.goto('file:///Users/vitormv/Projects/vmello-website/public/resume/index.html', { waitUntil: "networkidle0" });
13
14
  console.log('Awaiting page load...');
15
16
  await page.pdf({ format: 'A4', path: targetFile });
17
18
  await page.close();
19
  await browser.close();
20
21
  console.log('All done! PDF exported succesfully.');
22
};
23
24
const dest = path.resolve(`${__dirname}/../static/resume-html.pdf`);
25
26
exportResumeAsPdf(dest);
27