fix: don't clean up previous browser versions (#9568)

Since we moved to the central binaries cache it does not make sense to
clean up old binaries automatically because multiple installations can
use different versions. We expect the users to clean the cache from time
to time until we offer a CLI for managing the browsers.

Closes #9533
This commit is contained in:
Alex Rudenko 2023-01-24 17:28:00 +01:00 committed by GitHub
parent 3d249dc3a3
commit 344bc2af62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 5 deletions

View File

@ -504,6 +504,13 @@ export class BrowserFetcher {
#getFolderPath(revision: string): string {
return path.resolve(this.#downloadPath, `${this.#platform}-${revision}`);
}
/**
* @internal
*/
getDownloadPath(): string {
return this.#downloadPath;
}
}
function parseFolderPath(

View File

@ -94,13 +94,18 @@ export async function downloadBrowser(): Promise<void> {
logPolitely(
`${supportedProducts[product]} (${revisionInfo.revision}) downloaded to ${revisionInfo.folderPath}`
);
localRevisions = localRevisions.filter(revision => {
const otherRevisions = localRevisions.filter(revision => {
return revision !== revisionInfo.revision;
});
const cleanupOldVersions = localRevisions.map(revision => {
return browserFetcher.remove(revision);
});
Promise.all([...cleanupOldVersions]);
if (otherRevisions.length) {
logPolitely(
`Other installed ${
supportedProducts[product]
} browsers in ${browserFetcher.getDownloadPath()} include: ${otherRevisions.join(
', '
)}. Remove old revisions from ${browserFetcher.getDownloadPath()} if you don't need them.`
);
}
}
function onError(error: Error) {