Skip to content

Commit

Permalink
feat(install/download-hosts): allow multiple per browser (#2452)
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
Francois-Esquire committed Jun 18, 2020
1 parent 971bd88 commit 63924d9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/install/browserFetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ const DEFAULT_DOWNLOAD_HOSTS: { [key: string]: string } = {
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 {
if (browserName === 'chromium') {
return new Map<BrowserPlatform, string>([
Expand Down Expand Up @@ -76,7 +83,7 @@ function getDownloadUrl(browserName: BrowserName, platform: BrowserPlatform): st
}

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);
assert(urlTemplate, `ERROR: Playwright does not support ${browser.name} on ${platform}`);
return util.format(urlTemplate, serverHost, browser.revision);
Expand Down

0 comments on commit 63924d9

Please sign in to comment.