Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion docs/tools/lighthouse-audit.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,25 @@ async function cleanupAndPrepareReportsDir() {
await fs.promises.rm(reportsDir, {recursive: true});
} catch {}

await fs.promises.mkdir(reportsDir, {recursive: true});
try {
await fs.promises.mkdir(reportsDir, {recursive: true});
} catch (err) {
// If mkdir fails, try to create the entire path structure
const pathParts = reportsDir.split(path.sep);
let currentPath = pathParts[0] || path.sep;

for (let i = 1; i < pathParts.length; i++) {
currentPath = path.join(currentPath, pathParts[i]);
try {
await fs.promises.mkdir(currentPath);
} catch (mkdirErr) {
// Ignore EEXIST errors, but throw others
if (mkdirErr.code !== 'EEXIST') {
throw mkdirErr;
}
}
}
}
}

/**
Expand Down
Loading