A big commit with a bunch of node modules so I could run puppeteer for Walmart. Added some todos and Headway's templates.
This commit is contained in:
46
Scripts/node_modules/puppeteer/src/getConfiguration.ts
generated
vendored
46
Scripts/node_modules/puppeteer/src/getConfiguration.ts
generated
vendored
@ -10,6 +10,22 @@ import {join} from 'path';
|
||||
import {cosmiconfigSync} from 'cosmiconfig';
|
||||
import type {Configuration, Product} from 'puppeteer-core';
|
||||
|
||||
function getBooleanEnvVar(name: string) {
|
||||
const env = process.env[name];
|
||||
if (env === undefined) {
|
||||
return;
|
||||
}
|
||||
switch (env.toLowerCase()) {
|
||||
case '':
|
||||
case '0':
|
||||
case 'false':
|
||||
case 'off':
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
@ -27,7 +43,9 @@ function isSupportedProduct(product: unknown): product is Product {
|
||||
* @internal
|
||||
*/
|
||||
export const getConfiguration = (): Configuration => {
|
||||
const result = cosmiconfigSync('puppeteer').search();
|
||||
const result = cosmiconfigSync('puppeteer', {
|
||||
searchStrategy: 'global',
|
||||
}).search();
|
||||
const configuration: Configuration = result ? result.config : {};
|
||||
|
||||
configuration.logLevel = (process.env['PUPPETEER_LOGLEVEL'] ??
|
||||
@ -56,12 +74,32 @@ export const getConfiguration = (): Configuration => {
|
||||
|
||||
// Set skipDownload explicitly or from default
|
||||
configuration.skipDownload = Boolean(
|
||||
process.env['PUPPETEER_SKIP_DOWNLOAD'] ??
|
||||
process.env['npm_config_puppeteer_skip_download'] ??
|
||||
process.env['npm_package_config_puppeteer_skip_download'] ??
|
||||
getBooleanEnvVar('PUPPETEER_SKIP_DOWNLOAD') ??
|
||||
getBooleanEnvVar('npm_config_puppeteer_skip_download') ??
|
||||
getBooleanEnvVar('npm_package_config_puppeteer_skip_download') ??
|
||||
configuration.skipDownload
|
||||
);
|
||||
|
||||
// Set skipChromeDownload explicitly or from default
|
||||
configuration.skipChromeDownload = Boolean(
|
||||
getBooleanEnvVar('PUPPETEER_SKIP_CHROME_DOWNLOAD') ??
|
||||
getBooleanEnvVar('npm_config_puppeteer_skip_chrome_download') ??
|
||||
getBooleanEnvVar('npm_package_config_puppeteer_skip_chrome_download') ??
|
||||
configuration.skipChromeDownload
|
||||
);
|
||||
|
||||
// Set skipChromeDownload explicitly or from default
|
||||
configuration.skipChromeHeadlessShellDownload = Boolean(
|
||||
getBooleanEnvVar('PUPPETEER_SKIP_CHROME_HEADLESS_SHELL_DOWNLOAD') ??
|
||||
getBooleanEnvVar(
|
||||
'npm_config_puppeteer_skip_chrome_headless_shell_download'
|
||||
) ??
|
||||
getBooleanEnvVar(
|
||||
'npm_package_config_puppeteer_skip_chrome_headless_shell_download'
|
||||
) ??
|
||||
configuration.skipChromeHeadlessShellDownload
|
||||
);
|
||||
|
||||
// Prepare variables used in browser downloading
|
||||
if (!configuration.skipDownload) {
|
||||
configuration.browserRevision =
|
||||
|
||||
Reference in New Issue
Block a user