Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit ba7a0a3

Browse files
mxmulmarkdalgleish
authored andcommitted
feat(puppeteer): Add option to override the Chromium executable (#21)
The --puppeteer-executable-path option will be passed through to Puppeteer as the 'executablePath', allowing you to run a different version of Chromium than the one downloaded by Puppeteer.
1 parent 4cd8fbb commit ba7a0a3

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,14 @@ $ html-sketchapp --puppeteer-args="--no-sandbox --disable-setuid-sandbox" --file
110110

111111
*Note: Because Puppeteer args are prefixed with hyphens, you **must** use an equals sign and quotes when providing this option via the command line (as seen above).*
112112

113+
### Chromium executable
114+
115+
If you'd like to override the Chromium used by Puppeteer, you can provide a path to the executable with the `puppeteer-executable-path` option.
116+
117+
```bash
118+
$ html-sketchapp --puppeteer-executable-path google-chrome-unstable --file sketch.html --out-dir dist
119+
```
120+
113121
### Config file
114122

115123
All options can be provided via an `html-sketchapp.config.js` file.
@@ -122,7 +130,8 @@ module.exports = {
122130
Desktop: '1024x768',
123131
Mobile: '320x568'
124132
},
125-
puppeteerArgs: '--no-sandbox --disable-setuid-sandbox'
133+
puppeteerArgs: '--no-sandbox --disable-setuid-sandbox',
134+
puppeteerExecutablePath: 'google-chrome-unstable'
126135
};
127136
```
128137

bin/cli.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ require('yargs')
5151
'puppeteer-args': {
5252
type: 'string',
5353
describe: 'Set of command line arguments to be provided to the Chromium instance via Puppeteer, e.g. --puppeteer-args="--no-sandbox --disable-setuid-sandbox"'
54+
},
55+
'puppeteer-executable-path': {
56+
type: 'string',
57+
describe: 'Path to a Chromium executable to use instead of the one downloaded by Puppeteer.'
5458
}
5559
}, async argv => {
5660
try {
@@ -68,7 +72,11 @@ require('yargs')
6872
resources: [symbolsUrl.replace(/^(https?)/, '$1-get')],
6973
});
7074

71-
const browser = await puppeteer.launch({ args: argv.puppeteerArgs ? argv.puppeteerArgs.split(' ') : [] });
75+
const launchArgs = {
76+
args: argv.puppeteerArgs ? argv.puppeteerArgs.split(' ') : [],
77+
executablePath: argv.puppeteerExecutablePath,
78+
};
79+
const browser = await puppeteer.launch(launchArgs);
7280

7381
try {
7482
const page = await browser.newPage();

0 commit comments

Comments
 (0)