Optimization and potentially prevend leaving the repo in a broken state

This commit is contained in:
Joseph Garrone 2024-12-23 18:49:00 +01:00
parent cc3d0d61dd
commit 6de5fd4f96

View File

@ -60,6 +60,8 @@ export async function command(params: {
const ownedFilesRelativePaths_toAdd: string[] = []; const ownedFilesRelativePaths_toAdd: string[] = [];
const writeActions: (() => Promise<void>)[] = [];
for (const { uiModuleMeta, fileRelativePaths } of arr) { for (const { uiModuleMeta, fileRelativePaths } of arr) {
const uiModuleDirPath = await getInstalledModuleDirPath({ const uiModuleDirPath = await getInstalledModuleDirPath({
moduleName: uiModuleMeta.moduleName, moduleName: uiModuleMeta.moduleName,
@ -84,9 +86,11 @@ export async function command(params: {
uiModuleVersion: uiModuleMeta.version uiModuleVersion: uiModuleMeta.version
}); });
await fsPr.writeFile( writeActions.push(() =>
fsPr.writeFile(
pathJoin(buildContext.themeSrcDirPath, fileRelativePath), pathJoin(buildContext.themeSrcDirPath, fileRelativePath),
sourceCode sourceCode
)
); );
ownedFilesRelativePaths_toAdd.push(fileRelativePath); ownedFilesRelativePaths_toAdd.push(fileRelativePath);
@ -98,6 +102,8 @@ export async function command(params: {
process.exit(1); process.exit(1);
} }
await Promise.all(writeActions.map(action => action()));
await writeManagedGitignoreFile({ await writeManagedGitignoreFile({
buildContext, buildContext,
uiModuleMetas, uiModuleMetas,