Skip to content

Commit 2a73fc9

Browse files
committed
fixup! refactor(@angular/build): unify and deduplicate emitFilesToDisk across builders
1 parent 496c818 commit 2a73fc9

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎packages/angular/build/src/utils/emit-files-to-disk.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export async function emitFilesToDisk<T extends EmittableFile = EmittableFile>(
3636
return;
3737
}
3838

39-
const directoryExists = new Set<string>();
39+
const directoryCreationPromises = new Map<string, Promise<string | undefined>>();
4040

4141
await runConcurrent(files, MAX_CONCURRENT_WRITES, async (file) => {
4242
const fullFilePath = resolveDestinationPath(file);
@@ -46,9 +46,13 @@ export async function emitFilesToDisk<T extends EmittableFile = EmittableFile>(
4646

4747
// Ensure output subdirectories exist
4848
const fileBasePath = dirname(fullFilePath);
49-
if (fileBasePath && !directoryExists.has(fileBasePath)) {
50-
await mkdir(fileBasePath, { recursive: true });
51-
directoryExists.add(fileBasePath);
49+
if (fileBasePath) {
50+
let mkdirPromise = directoryCreationPromises.get(fileBasePath);
51+
if (!mkdirPromise) {
52+
mkdirPromise = mkdir(fileBasePath, { recursive: true });
53+
directoryCreationPromises.set(fileBasePath, mkdirPromise);
54+
}
55+
await mkdirPromise;
5256
}
5357

5458
if (file.origin === 'memory') {

0 commit comments

Comments
 (0)