mirror of
https://github.com/microsoft/playwright.git
synced 2024-09-11 20:37:54 +03:00
fix: properly download browsers (#1173)
Playwright API is parametrized with a `downloadPath` - a path that is used to download browsers and to look for downloaded browsers. This patch starts respecting `downloadPath` as part of `download-browser.js` utility.
This commit is contained in:
parent
cbf65a9c56
commit
d5951b4fc4
@ -14,8 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
async function downloadBrowser(browser) {
|
||||
const browserType = require('.')[browser];
|
||||
async function downloadBrowser(browserType) {
|
||||
const browser = browserType.name();
|
||||
let progressBar = null;
|
||||
let lastDownloadedBytes = 0;
|
||||
function onProgress(downloadedBytes, totalBytes) {
|
||||
|
@ -25,36 +25,37 @@ try {
|
||||
} catch (e) {
|
||||
}
|
||||
const {downloadBrowser} = require('./download-browser');
|
||||
const playwright = require('.');
|
||||
|
||||
(async function() {
|
||||
const protocolGenerator = require('./utils/protocol-types-generator');
|
||||
try {
|
||||
const chromeRevision = await downloadAndCleanup('chromium');
|
||||
const chromeRevision = await downloadAndCleanup(playwright.chromium);
|
||||
await protocolGenerator.generateChromiunProtocol(chromeRevision);
|
||||
} catch (e) {
|
||||
console.warn(e.message);
|
||||
}
|
||||
|
||||
try {
|
||||
const firefoxRevision = await downloadAndCleanup('firefox');
|
||||
const firefoxRevision = await downloadAndCleanup(playwright.firefox);
|
||||
await protocolGenerator.generateFirefoxProtocol(firefoxRevision);
|
||||
} catch (e) {
|
||||
console.warn(e.message);
|
||||
}
|
||||
|
||||
try {
|
||||
const webkitRevision = await downloadAndCleanup('webkit');
|
||||
const webkitRevision = await downloadAndCleanup(playwright.webkit);
|
||||
await protocolGenerator.generateWebKitProtocol(webkitRevision);
|
||||
} catch (e) {
|
||||
console.warn(e.message);
|
||||
}
|
||||
})();
|
||||
|
||||
async function downloadAndCleanup(browser) {
|
||||
const revisionInfo = await downloadBrowser(browser);
|
||||
async function downloadAndCleanup(browserType) {
|
||||
const revisionInfo = await downloadBrowser(browserType);
|
||||
|
||||
// Remove previous revisions.
|
||||
const fetcher = require('.')[browser]._createBrowserFetcher();
|
||||
const fetcher = browserType._createBrowserFetcher();
|
||||
const localRevisions = await fetcher.localRevisions();
|
||||
const cleanupOldVersions = localRevisions.filter(revision => revision !== revisionInfo.revision).map(revision => fetcher.remove(revision));
|
||||
await Promise.all([...cleanupOldVersions]);
|
||||
|
@ -14,4 +14,5 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
const {downloadBrowser} = require('playwright-core/download-browser');
|
||||
downloadBrowser('chromium');
|
||||
const playwright = require('.');
|
||||
downloadBrowser(playwright.chromium);
|
||||
|
@ -14,4 +14,5 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
const {downloadBrowser} = require('playwright-core/download-browser');
|
||||
downloadBrowser('firefox');
|
||||
const playwright = require('.');
|
||||
downloadBrowser(playwright.firefox);
|
||||
|
@ -14,4 +14,5 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
const {downloadBrowser} = require('playwright-core/download-browser');
|
||||
downloadBrowser('webkit');
|
||||
const playwright = require('.');
|
||||
downloadBrowser(playwright.webkit);
|
||||
|
@ -14,8 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
const {downloadBrowser} = require('playwright-core/download-browser');
|
||||
const playwright = require('.');
|
||||
(async function() {
|
||||
await downloadBrowser('chromium');
|
||||
await downloadBrowser('firefox');
|
||||
await downloadBrowser('webkit');
|
||||
await downloadBrowser(playwright.chromium);
|
||||
await downloadBrowser(playwright.firefox);
|
||||
await downloadBrowser(playwright.webkit);
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user