0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

small fix to an incorrect check (#10300)

This commit is contained in:
Fred K. Schott 2024-03-04 03:01:20 -08:00 committed by GitHub
parent cb00c8b692
commit 725f83fdb9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -72,12 +72,12 @@ export function fileURLIntegration(): AstroIntegration {
unlinks.push(fs.promises.unlink(url));
}
await Promise.all(unlinks);
// Delete the assets directory if it is empty.
// NOTE(fks): Ignore errors here because this is expected to fail
// if the directory contains files, or if it does not exist.
// If it errors for some unknown reason, it's not a big deal.
const assetDir = new URL(config.build.assets, config.outDir);
const assetFiles = await fs.promises.readdir(assetDir);
if (!assetFiles.length) {
// Directory is empty, delete it.
await fs.promises.rmdir(assetDir);
}
await fs.promises.rmdir(assetDir).catch(() => []);
} else {
// Move files back over to the dist output path
const moves: Promise<unknown>[] = [];