-
Notifications
You must be signed in to change notification settings - Fork 31
/
index.js
28 lines (23 loc) · 927 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/**
* This file is part of the spiritix/php-chrome-html2pdf package.
*
* @copyright Copyright (c) Matthias Isler <[email protected]>
* @license MIT
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import getStdin from 'get-stdin';
import { program } from 'commander';
import Converter from './lib/Converter.js';
(async () => {
program
.option('-o, --options [options]', 'PDF options for puppeteer')
.option('-l, --launchOptions [launchOptions]', 'Launch Options for puppeteer')
.parse()
const options = JSON.parse(program.opts().options);
const launchOptions = JSON.parse(program.opts().launchOptions);
const converter = new Converter(await getStdin(), options, launchOptions);
const buffer = await converter.run();
process.stdout.write(buffer.toString('binary'), 'binary');
})();