1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | import { PuppeteerNode } from './node/Puppeteer.js';
|
17 | import { PUPPETEER_REVISIONS } from './revisions.js';
|
18 | import pkgDir from 'pkg-dir';
|
19 | export const initializePuppeteerNode = (packageName) => {
|
20 | const puppeteerRootDirectory = pkgDir.sync(__dirname);
|
21 | let preferredRevision = PUPPETEER_REVISIONS.chromium;
|
22 | const isPuppeteerCore = packageName === 'puppeteer-core';
|
23 |
|
24 | const productName = isPuppeteerCore
|
25 | ? undefined
|
26 | : process.env.PUPPETEER_PRODUCT ||
|
27 | process.env.npm_config_puppeteer_product ||
|
28 | process.env.npm_package_config_puppeteer_product;
|
29 | if (!isPuppeteerCore && productName === 'firefox')
|
30 | preferredRevision = PUPPETEER_REVISIONS.firefox;
|
31 | return new PuppeteerNode({
|
32 | projectRoot: puppeteerRootDirectory,
|
33 | preferredRevision,
|
34 | isPuppeteerCore,
|
35 | productName: productName,
|
36 | });
|
37 | };
|
38 |
|
\ | No newline at end of file |