Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix(install): only install browsers needed by this revision (#2112)

Pavel Feldmand95891ebadbc
diff --git a/src/install/installer.ts b/src/install/installer.ts
index e18db5d28c..7806c2e6fa 100644
--- a/src/install/installer.ts
+++ b/src/install/installer.ts
@@ -63,7 +63,6 @@ async function validateCache(packagePath: string, browsersPath: string, linksDir
let downloadedBrowsers = (await fsReaddirAsync(browsersPath)).map(file => path.join(browsersPath, file));
downloadedBrowsers = downloadedBrowsers.filter(file => browserPaths.isBrowserDirectory(file));
const directories = new Set<string>(downloadedBrowsers);
- directories.delete(path.join(browsersPath, '.links'));
for (const browser of allBrowsers)
directories.delete(browserPaths.browserDirectory(browsersPath, browser));
for (const directory of directories) {
@@ -71,8 +70,9 @@ async function validateCache(packagePath: string, browsersPath: string, linksDir
await removeFolderAsync(directory).catch(e => {});
}
- // 3. Install missing browsers.
- for (const browser of allBrowsers) {
+ // 3. Install missing browsers for this package.
+ const myBrowsers = JSON.parse((await fsReadFileAsync(path.join(packagePath, 'browsers.json'))).toString())['browsers'];
+ for (const browser of myBrowsers) {
const browserPath = browserPaths.browserDirectory(browsersPath, browser);
if (await browserFetcher.downloadBrowserWithProgressBar(browserPath, browser))
await installBrowser(packagePath, browserPath, browser);