UNPKG

1.59 kBJavaScriptView Raw
1/**
2 * Copyright 2020 Google Inc. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import { PuppeteerNode } from './node/Puppeteer.js';
17import { PUPPETEER_REVISIONS } from './revisions.js';
18import pkgDir from 'pkg-dir';
19export const initializePuppeteerNode = (packageName) => {
20 const puppeteerRootDirectory = pkgDir.sync(__dirname);
21 let preferredRevision = PUPPETEER_REVISIONS.chromium;
22 const isPuppeteerCore = packageName === 'puppeteer-core';
23 // puppeteer-core ignores environment variables
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//# sourceMappingURL=initialize-node.js.map
\No newline at end of file