feat: Default to not downloading if explicit browser path is set (#9440)

Fixed: #9419
This commit is contained in:
Evan Carroll 2022-12-20 07:50:02 -06:00 committed by GitHub
parent 842008102f
commit d2536d7cf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 37 deletions

View File

@ -433,8 +433,7 @@ RUN apk add --no-cache \
... ...
# Tell Puppeteer to skip installing Chrome. We'll be using the installed package. # Tell Puppeteer to skip installing Chrome. We'll be using the installed package.
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \ ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
# Puppeteer v13.5.0 works with Chromium 100. # Puppeteer v13.5.0 works with Chromium 100.
RUN yarn add puppeteer@13.5.0 RUN yarn add puppeteer@13.5.0

View File

@ -24,38 +24,60 @@ export const getConfiguration = (): Configuration => {
const configuration: Configuration = result ? result.config : {}; const configuration: Configuration = result ? result.config : {};
// Merging environment variables. // Merging environment variables.
configuration.browserRevision = configuration.defaultProduct = (process.env['PUPPETEER_PRODUCT'] ??
process.env['PUPPETEER_CHROMIUM_REVISION'] ?? process.env['npm_config_puppeteer_product'] ??
process.env['PUPPETEER_BROWSER_REVISION'] ?? process.env['npm_package_config_puppeteer_product'] ??
process.env['npm_config_puppeteer_browser_revision'] ?? configuration.defaultProduct ??
process.env['npm_package_config_puppeteer_browser_revision'] ?? 'chrome') as Product;
configuration.browserRevision;
configuration.executablePath =
process.env['PUPPETEER_EXECUTABLE_PATH'] ??
process.env['npm_config_puppeteer_executable_path'] ??
process.env['npm_package_config_puppeteer_executable_path'] ??
configuration.executablePath;
// Default to skipDownload if executablePath is set
if (configuration.executablePath) {
configuration.skipDownload = true;
}
// 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'] ??
process.env['PUPPETEER_SKIP_CHROMIUM_DOWNLOAD'] ??
process.env['npm_config_puppeteer_skip_chromium_download'] ??
process.env['npm_package_config_puppeteer_skip_chromium_download'] ??
configuration.skipDownload
);
// Prepare variables used in browser downloading
if (!configuration.skipDownload) {
configuration.browserRevision =
process.env['PUPPETEER_CHROMIUM_REVISION'] ??
process.env['PUPPETEER_BROWSER_REVISION'] ??
process.env['npm_config_puppeteer_browser_revision'] ??
process.env['npm_package_config_puppeteer_browser_revision'] ??
configuration.browserRevision;
configuration.downloadHost =
process.env['PUPPETEER_DOWNLOAD_HOST'] ??
process.env['npm_config_puppeteer_download_host'] ??
process.env['npm_package_config_puppeteer_download_host'] ??
configuration.downloadHost;
configuration.downloadPath =
process.env['PUPPETEER_DOWNLOAD_PATH'] ??
process.env['npm_config_puppeteer_download_path'] ??
process.env['npm_package_config_puppeteer_download_path'] ??
configuration.downloadPath;
}
configuration.cacheDirectory = configuration.cacheDirectory =
process.env['PUPPETEER_CACHE_DIR'] ?? process.env['PUPPETEER_CACHE_DIR'] ??
process.env['npm_config_puppeteer_cache_dir'] ?? process.env['npm_config_puppeteer_cache_dir'] ??
process.env['npm_package_config_puppeteer_cache_dir'] ?? process.env['npm_package_config_puppeteer_cache_dir'] ??
configuration.cacheDirectory ?? configuration.cacheDirectory ??
join(homedir(), '.cache', 'puppeteer'); join(homedir(), '.cache', 'puppeteer');
configuration.downloadHost =
process.env['PUPPETEER_DOWNLOAD_HOST'] ??
process.env['npm_config_puppeteer_download_host'] ??
process.env['npm_package_config_puppeteer_download_host'] ??
configuration.downloadHost;
configuration.downloadPath =
process.env['PUPPETEER_DOWNLOAD_PATH'] ??
process.env['npm_config_puppeteer_download_path'] ??
process.env['npm_package_config_puppeteer_download_path'] ??
configuration.downloadPath;
configuration.executablePath =
process.env['PUPPETEER_EXECUTABLE_PATH'] ??
process.env['npm_config_puppeteer_executable_path'] ??
process.env['npm_package_config_puppeteer_executable_path'] ??
configuration.executablePath;
configuration.defaultProduct = (process.env['PUPPETEER_PRODUCT'] ??
process.env['npm_config_puppeteer_product'] ??
process.env['npm_package_config_puppeteer_product'] ??
configuration.defaultProduct ??
'chrome') as Product;
configuration.temporaryDirectory = configuration.temporaryDirectory =
process.env['PUPPETEER_TMP_DIR'] ?? process.env['PUPPETEER_TMP_DIR'] ??
process.env['npm_config_puppeteer_tmp_dir'] ?? process.env['npm_config_puppeteer_tmp_dir'] ??
@ -72,15 +94,6 @@ export const getConfiguration = (): Configuration => {
configuration.experiments.macArmChromiumEnabled configuration.experiments.macArmChromiumEnabled
); );
configuration.skipDownload = Boolean(
process.env['PUPPETEER_SKIP_DOWNLOAD'] ??
process.env['npm_config_puppeteer_skip_download'] ??
process.env['npm_package_config_puppeteer_skip_download'] ??
process.env['PUPPETEER_SKIP_CHROMIUM_DOWNLOAD'] ??
process.env['npm_config_puppeteer_skip_chromium_download'] ??
process.env['npm_package_config_puppeteer_skip_chromium_download'] ??
configuration.skipDownload
);
configuration.logLevel = (process.env['PUPPETEER_LOGLEVEL'] ?? configuration.logLevel = (process.env['PUPPETEER_LOGLEVEL'] ??
process.env['npm_config_LOGLEVEL'] ?? process.env['npm_config_LOGLEVEL'] ??
process.env['npm_package_config_LOGLEVEL'] ?? process.env['npm_package_config_LOGLEVEL'] ??