mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix: use puppeteer node for installation script (#9489)
Fixed: https://github.com/puppeteer/puppeteer/issues/9470
This commit is contained in:
parent
29b948197d
commit
9bf90d9f4b
@ -8,8 +8,10 @@ sidebar_label: createBrowserFetcher
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
createBrowserFetcher: (
|
createBrowserFetcher: (
|
||||||
options: Partial<
|
options?:
|
||||||
import('puppeteer-core/internal/puppeteer-core.js').BrowserFetcherOptions
|
| Partial<
|
||||||
>
|
import('puppeteer-core/internal/puppeteer-core.js').BrowserFetcherOptions
|
||||||
|
>
|
||||||
|
| undefined
|
||||||
) => import('puppeteer-core/internal/puppeteer-core.js').BrowserFetcher;
|
) => import('puppeteer-core/internal/puppeteer-core.js').BrowserFetcher;
|
||||||
```
|
```
|
||||||
|
@ -8,15 +8,17 @@ sidebar_label: PuppeteerNode.createBrowserFetcher
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class PuppeteerNode {
|
class PuppeteerNode {
|
||||||
createBrowserFetcher(options: Partial<BrowserFetcherOptions>): BrowserFetcher;
|
createBrowserFetcher(
|
||||||
|
options?: Partial<BrowserFetcherOptions>
|
||||||
|
): BrowserFetcher;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
| Parameter | Type | Description |
|
||||||
| --------- | ---------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
|
| --------- | ---------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
|
||||||
| options | Partial<[BrowserFetcherOptions](./puppeteer.browserfetcheroptions.md)> | Set of configurable options to specify the settings of the BrowserFetcher. |
|
| options | Partial<[BrowserFetcherOptions](./puppeteer.browserfetcheroptions.md)> | <i>(Optional)</i> Set of configurable options to specify the settings of the BrowserFetcher. |
|
||||||
|
|
||||||
**Returns:**
|
**Returns:**
|
||||||
|
|
||||||
|
@ -289,7 +289,7 @@ export class PuppeteerNode extends Puppeteer {
|
|||||||
* @returns A new BrowserFetcher instance.
|
* @returns A new BrowserFetcher instance.
|
||||||
*/
|
*/
|
||||||
createBrowserFetcher(
|
createBrowserFetcher(
|
||||||
options: Partial<BrowserFetcherOptions>
|
options: Partial<BrowserFetcherOptions> = {}
|
||||||
): BrowserFetcher {
|
): BrowserFetcher {
|
||||||
const downloadPath = this.defaultDownloadPath;
|
const downloadPath = this.defaultDownloadPath;
|
||||||
if (downloadPath) {
|
if (downloadPath) {
|
||||||
@ -304,6 +304,9 @@ export class PuppeteerNode extends Puppeteer {
|
|||||||
if (this.configuration.downloadHost) {
|
if (this.configuration.downloadHost) {
|
||||||
options.host = this.configuration.downloadHost;
|
options.host = this.configuration.downloadHost;
|
||||||
}
|
}
|
||||||
|
if (this.configuration.defaultProduct) {
|
||||||
|
options.product = this.configuration.defaultProduct;
|
||||||
|
}
|
||||||
return new BrowserFetcher(options as BrowserFetcherOptions);
|
return new BrowserFetcher(options as BrowserFetcherOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,9 @@
|
|||||||
|
|
||||||
import https, {RequestOptions} from 'https';
|
import https, {RequestOptions} from 'https';
|
||||||
import createHttpsProxyAgent, {HttpsProxyAgentOptions} from 'https-proxy-agent';
|
import createHttpsProxyAgent, {HttpsProxyAgentOptions} from 'https-proxy-agent';
|
||||||
import {join} from 'path';
|
|
||||||
import ProgressBar from 'progress';
|
import ProgressBar from 'progress';
|
||||||
import {getProxyForUrl} from 'proxy-from-env';
|
import {getProxyForUrl} from 'proxy-from-env';
|
||||||
import {BrowserFetcher} from 'puppeteer-core';
|
import {PuppeteerNode} from 'puppeteer-core/internal/node/PuppeteerNode.js';
|
||||||
import {PUPPETEER_REVISIONS} from 'puppeteer-core/internal/revisions.js';
|
import {PUPPETEER_REVISIONS} from 'puppeteer-core/internal/revisions.js';
|
||||||
import URL from 'url';
|
import URL from 'url';
|
||||||
import {getConfiguration} from '../getConfiguration.js';
|
import {getConfiguration} from '../getConfiguration.js';
|
||||||
@ -42,14 +41,10 @@ export async function downloadBrowser(): Promise<void> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const puppeteer = new PuppeteerNode({configuration, isPuppeteerCore: false});
|
||||||
|
|
||||||
const product = configuration.defaultProduct!;
|
const product = configuration.defaultProduct!;
|
||||||
const browserFetcher = new BrowserFetcher({
|
const browserFetcher = puppeteer.createBrowserFetcher();
|
||||||
product,
|
|
||||||
host: configuration.downloadHost,
|
|
||||||
path:
|
|
||||||
configuration.downloadPath ??
|
|
||||||
join(configuration.cacheDirectory!, product),
|
|
||||||
});
|
|
||||||
|
|
||||||
let revision = configuration.browserRevision;
|
let revision = configuration.browserRevision;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user