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

Don't suggest to install Chromium in error message if the current platform cannot resolve Chromium by chrome-launcher module #476

Merged
merged 5 commits into from
Sep 10, 2022
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
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