mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
feat(install/download-hosts): allow multiple per browser (#2452)
In addition to `PLAYWRIGHT_DOWNLOAD_HOST` env variable, this patch adds a per-browser configuration: - `PLAYWRIGHT_CHROMIUM_DOWNLOAD_HOST` - `PLAYWRIGHT_FIREFOX_DOWNLOAD_HOST` - `PLAYWRIGHT_WEBKIT_DOWNLOAD_HOST`
This commit is contained in:
parent
971bd88922
commit
63924d9a26
@ -40,6 +40,13 @@ const DEFAULT_DOWNLOAD_HOSTS: { [key: string]: string } = {
|
|||||||
webkit: 'https://playwright.azureedge.net',
|
webkit: 'https://playwright.azureedge.net',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const ENV_DOWNLOAD_HOSTS: { [key: string]: string } = {
|
||||||
|
default: 'PLAYWRIGHT_DOWNLOAD_HOST',
|
||||||
|
chromium: 'PLAYWRIGHT_CHROMIUM_DOWNLOAD_HOST',
|
||||||
|
firefox: 'PLAYWRIGHT_FIREFOX_DOWNLOAD_HOST',
|
||||||
|
webkit: 'PLAYWRIGHT_WEBKIT_DOWNLOAD_HOST',
|
||||||
|
};
|
||||||
|
|
||||||
function getDownloadUrl(browserName: BrowserName, platform: BrowserPlatform): string | undefined {
|
function getDownloadUrl(browserName: BrowserName, platform: BrowserPlatform): string | undefined {
|
||||||
if (browserName === 'chromium') {
|
if (browserName === 'chromium') {
|
||||||
return new Map<BrowserPlatform, string>([
|
return new Map<BrowserPlatform, string>([
|
||||||
@ -76,7 +83,7 @@ function getDownloadUrl(browserName: BrowserName, platform: BrowserPlatform): st
|
|||||||
}
|
}
|
||||||
|
|
||||||
function revisionURL(browser: BrowserDescriptor, platform = browserPaths.hostPlatform): string {
|
function revisionURL(browser: BrowserDescriptor, platform = browserPaths.hostPlatform): string {
|
||||||
const serverHost = getFromENV('PLAYWRIGHT_DOWNLOAD_HOST') || DEFAULT_DOWNLOAD_HOSTS[browser.name];
|
const serverHost = getFromENV(ENV_DOWNLOAD_HOSTS[browser.name]) || getFromENV(ENV_DOWNLOAD_HOSTS.default) || DEFAULT_DOWNLOAD_HOSTS[browser.name];
|
||||||
const urlTemplate = getDownloadUrl(browser.name, platform);
|
const urlTemplate = getDownloadUrl(browser.name, platform);
|
||||||
assert(urlTemplate, `ERROR: Playwright does not support ${browser.name} on ${platform}`);
|
assert(urlTemplate, `ERROR: Playwright does not support ${browser.name} on ${platform}`);
|
||||||
return util.format(urlTemplate, serverHost, browser.revision);
|
return util.format(urlTemplate, serverHost, browser.revision);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user