feat: make it possible to run install.js
script with puppeteer-core
(#5325)
Co-authored-by: Mathias Bynens <mathias@qiwi.be>
This commit is contained in:
parent
c283fea6c5
commit
0d243b7a0f
@ -371,6 +371,7 @@ In most cases, you'll be fine using the `puppeteer` package.
|
||||
However, you should use `puppeteer-core` if:
|
||||
- you're building another end-user product or library atop of DevTools protocol. For example, one might build a PDF generator using `puppeteer-core` and write a custom `install.js` script that downloads [`headless_shell`](https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md) instead of Chromium to save disk space.
|
||||
- you're bundling Puppeteer to use in Chrome Extension / browser with the DevTools protocol where downloading an additional Chromium binary is unnecessary.
|
||||
- you're building a set of tools where `puppeteer-core` is one of the ingredients and you want to postpone `install.js` script execution until Chromium is about to be used.
|
||||
|
||||
When using `puppeteer-core`, remember to change the *include* line:
|
||||
|
||||
|
12
install.js
12
install.js
@ -14,10 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// puppeteer-core should not install anything.
|
||||
if (require('./package.json').name === 'puppeteer-core')
|
||||
return;
|
||||
|
||||
/**
|
||||
* This file is part of public API.
|
||||
*
|
||||
* By default, the `puppeteer` package runs this script during the installation
|
||||
* process unless one of the env flags is provided.
|
||||
* `puppeteer-core` package doesn't include this step at all. However, it's
|
||||
* still possible to install Chromium using this script when necessary.
|
||||
*/
|
||||
if (process.env.PUPPETEER_SKIP_CHROMIUM_DOWNLOAD) {
|
||||
logPolitely('**INFO** Skipping Chromium download. "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" environment variable was found.');
|
||||
return;
|
||||
|
@ -22,4 +22,5 @@ const packagePath = path.join(__dirname, '..', 'package.json');
|
||||
const json = require(packagePath);
|
||||
|
||||
json.name = 'puppeteer-core';
|
||||
delete json.scripts.install;
|
||||
fs.writeFileSync(packagePath, JSON.stringify(json, null, ' '));
|
||||
|
Loading…
Reference in New Issue
Block a user