Skip to content

Commit 9b2f3f6

Browse files
feat: batch writes in template build (#205)
1 parent da5a772 commit 9b2f3f6

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/bin/commands/build.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -306,23 +306,23 @@ export const buildCommand: yargs.CommandModule<
306306
updateSpinnerMessage(index, "Writing files to sandbox...")
307307
);
308308

309-
await Promise.all(
310-
filePaths.map((filePath) =>
311-
retryWithDelay(
312-
async () => {
309+
// Use batch write for more efficient file uploads
310+
await retryWithDelay(
311+
async () => {
312+
const files = await Promise.all(
313+
filePaths.map(async (filePath) => {
313314
const fullPath = path.join(argv.directory, filePath);
314315
const content = await fs.readFile(fullPath);
315-
const dirname = path.dirname(filePath);
316-
await session.fs.mkdir(dirname, true);
317-
await session.fs.writeFile(filePath, content, {
318-
create: true,
319-
overwrite: true,
320-
});
321-
},
322-
3,
323-
200
324-
)
325-
)
316+
return {
317+
path: filePath,
318+
content,
319+
};
320+
})
321+
);
322+
await session.fs.batchWrite(files);
323+
},
324+
3,
325+
200
326326
).catch((error) => {
327327
throw new Error(`Failed to write files to sandbox: ${error}`);
328328
});

0 commit comments

Comments
 (0)