Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use locally installed browser #48

Merged
merged 1 commit into from
Dec 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions core/command/pdf.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const chalk = require('chalk')
const puppeteer = require('puppeteer')
const puppeteer = require('puppeteer-core')
const { getPlatform } = require('chrome-launcher/dist/utils.js')
const chromeFinder = require('chrome-launcher/dist/chrome-finder.js')

function evalCalcExpression (value) {
const expression = value
Expand All @@ -11,7 +13,11 @@ function evalCalcExpression (value) {
}

async function handler ({ cwd, output }) {
let browser = await puppeteer.launch()
const executablePath = process.env.PUPPETEER_EXECUTABLE_PATH || (await (chromeFinder)[getPlatform()]())[0]
if (!executablePath) {
throw new Error('Chrome / Chromium is not installed or environment variable PUPPETEER_EXECUTABLE_PATH is not set')
}
let browser = await puppeteer.launch({ executablePath })
let page = await browser.newPage()

await page.goto(`file://${cwd}/index.html`)
Expand Down
133 changes: 100 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"dependencies": {
"browser-sync": "^2.26.5",
"chalk": "^2.4.2",
"chrome-launcher": "^0.12.0",
"del": "^3.0.0",
"execa": "^1.0.0",
"gh-pages": "^2.0.1",
Expand All @@ -56,7 +57,7 @@
"inquirer": "^6.3.1",
"listr": "^0.14.3",
"merge-stream": "^1.0.1",
"puppeteer": "^1.15.0",
"puppeteer-core": "^2.0.0",
"semver": "^5.7.0",
"tmp": "0.0.33",
"update-notifier": "^2.5.0",
Expand Down
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ Options:

**`$ shower pdf` - Converts the presentation to PDF**

The browser that [implements the Chrome Debugging Protocol](https://github.com/cyrus-and/chrome-remote-interface/#implementations) is required.
If you installed Chrome / Chromium to the custom path or use another browser, set PUPPETEER_EXECUTABLE_PATH environment variable.

```
Options:
--output, -o File name [string] [default: "index.pdf"]
Expand Down