Skip to content

Commit

Permalink
Merge pull request #476 from marp-team/improve-chrome-not-resolvable-…
Browse files Browse the repository at this point in the history
…error-message

Don't suggest to install Chromium in error message if the current platform cannot resolve Chromium by `chrome-launcher` module
  • Loading branch information
yhatt authored Sep 10, 2022
2 parents 1c88eb2 + e7c0065 commit 8fcc744
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

### Fixed

- Don't suggest to install Chromium in error message if the current platform cannot resolve Chromium by `chrome-launcher` module ([#475](https://github.com/marp-team/marp-cli/issues/475), [#476](https://github.com/marp-team/marp-cli/pull/476))

### Changed

- Upgrade Node.js and dependencies ([#473](https://github.com/marp-team/marp-cli/pull/473))
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ npx @marp-team/marp-cli@latest -w slide-deck.md
npx @marp-team/marp-cli@latest -s ./slides
```

> :information_source: You have to install [Google Chrome], [Chromium], or [Microsoft Edge] to convert slide deck into PDF, PPTX, and image(s).
> :information_source: You have to install [Google Chrome]<!--, [Chromium], --> or [Microsoft Edge] to convert slide deck into PDF, PPTX, and image(s).
[google chrome]: https://www.google.com/chrome/
[chromium]: https://www.chromium.org/
Expand Down Expand Up @@ -121,19 +121,19 @@ When you want to output the converted result to another directory with keeping t

### Convert to PDF (`--pdf`)

If you passed `--pdf` option or the output filename specified by `--output` (`-o`) option ends with `.pdf`, Marp CLI will try to convert into PDF file by using [Google Chrome], [Chromium], [Microsoft Edge], or a Chromium based browser.
If you passed `--pdf` option or the output filename specified by `--output` (`-o`) option ends with `.pdf`, Marp CLI will try to convert Markdown into PDF file through the browser.

```bash
marp --pdf slide-deck.md
marp slide-deck.md -o converted.pdf
```

> :information_source: All kind of conversions except HTML require [Google Chrome], [Chromium], [Microsoft Edge], or a Chromium based browser. When an unexpected problem has occurred while converting, please update your browser to the latest version or try installing [Google Chrome Canary].
>
> If you want to use a browser other than Google Chrome, Chromium, or Microsoft Edge, specify the path to a Chromium based browser using the `CHROME_PATH` environment variable. For example: `CHROME_PATH=$(which brave) marp --pdf slide-deck.md`
All kind of conversions except HTML _require to install [Google Chrome]<!--, [Chromium]-->, [Microsoft Edge], or [Chromium] (flavored) browser._ When an unexpected problem has occurred while converting, please update your browser to the latest version or try installing [Google Chrome Canary].

[google chrome canary]: https://www.google.com/chrome/canary/

> :information_source: If you want to use Chromium or flavored browsers to convert, you have to specify the path to the browser binary through `CHROME_PATH` environment variable. For example: `CHROME_PATH=$(which brave) marp --pdf slide-deck.md`
If your slide deck had included [Marpit presenter notes] as HTML comment, you can add note annotations to the lower left by using `--pdf-notes` option together with `--pdf`.

[marpit presenter notes]: https://marpit.marp.app/usage?id=presenter-notes
Expand Down
8 changes: 7 additions & 1 deletion src/utils/puppeteer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,14 @@ export const generatePuppeteerLaunchArgs = async () => {
if (!executablePath) {
if (findChromeError) warn(findChromeError.message)

// https://github.com/marp-team/marp-cli/issues/475
// https://github.com/GoogleChrome/chrome-launcher/issues/278
const chromiumResolvable = process.platform === 'linux'

error(
'You have to install Google Chrome, Chromium, or Microsoft Edge to convert slide deck with current options.',
`You have to install Google Chrome${
chromiumResolvable ? ', Chromium,' : ''
} or Microsoft Edge to convert slide deck with current options.`,
CLIErrorCode.NOT_FOUND_CHROMIUM
)
}
Expand Down
5 changes: 1 addition & 4 deletions test/utils/puppeteer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,7 @@ describe('#generatePuppeteerLaunchArgs', () => {
jest.spyOn(edgeFinder(), 'findEdgeInstallation').mockImplementation()

await expect(puppeteerUtils().generatePuppeteerLaunchArgs).rejects.toThrow(
new (CLIError())(
'You have to install Google Chrome, Chromium, or Microsoft Edge to convert slide deck with current options.',
CLIErrorCode.NOT_FOUND_CHROMIUM
)
'You have to install Google Chrome'
)
expect(warn).toHaveBeenCalledWith(
expect.stringContaining('Error in chrome finder')
Expand Down

0 comments on commit 8fcc744

Please sign in to comment.