MCPcopy Index your code
hub / github.com/shower/shower / handler

Function handler

packages/cli/core/command/pdf.js:7–42  ·  view source on GitHub ↗
({ cwd, output })

Source from the content-addressed store, hash-verified

5import { runTask } from '../lib/task.js';
6
7async function handler ({ cwd, output }) {
8 if (!path.isAbsolute(output)) {
9 output = path.join(cwd, output);
10 }
11
12 const executablePath = await ensureBrowser();
13
14 await runTask('Printing slides', async () => {
15 const browser = await puppeteer.launch({ executablePath });
16
17 try {
18 const page = await browser.newPage();
19
20 await page.goto(`file://${cwd}/index.html`, {
21 waitUntil: 'networkidle0',
22 });
23
24 const { width, height } = await page.evaluate(() => {
25 const slide = document.querySelector('.slide');
26
27 return {
28 width: slide.offsetWidth,
29 height: slide.offsetHeight,
30 };
31 });
32
33 await page.pdf({
34 path: output,
35 width: `${width}px`,
36 height: `${height}px`,
37 });
38 } finally {
39 await browser.close();
40 }
41 });
42}
43
44function builder (yargs) {
45 return yargs

Callers

nothing calls this directly

Calls 2

ensureBrowserFunction · 0.90
runTaskFunction · 0.90

Tested by

no test coverage detected