fix: collect all errors in removeFolders (#28239)

This PR fixes
https://github.com/microsoft/playwright/pull/27790#pullrequestreview-1738958803.
Previously this function returns only the first error when some of the
promises fail. But the type annotation suggests that the original
intention was to collect all the errors. This commit fixes the error
values, and unexpected `TypeError: object is not iterable`.
This commit is contained in:
itchyny 2023-11-20 18:58:10 +09:00 committed by GitHub
parent 3f55587dd8
commit 440f5e5d2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,8 +28,8 @@ export async function mkdirIfNeeded(filePath: string) {
export async function removeFolders(dirs: string[]): Promise<Error[]> { export async function removeFolders(dirs: string[]): Promise<Error[]> {
return await Promise.all(dirs.map((dir: string) => return await Promise.all(dirs.map((dir: string) =>
fs.promises.rm(dir, { recursive: true, force: true, maxRetries: 10 }) fs.promises.rm(dir, { recursive: true, force: true, maxRetries: 10 }).catch(e => e)
)).catch(e => e); ));
} }
export function canAccessFile(file: string) { export function canAccessFile(file: string) {