Skip to content

Commit 1cadf72

Browse files
committed
chore: apply code review
1 parent 1797ed9 commit 1cadf72

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/generators/legacy-html/utils/safeCopy.mjs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,22 @@ import { join } from 'node:path';
1414
export async function safeCopy(srcDir, targetDir) {
1515
const files = await readdir(srcDir);
1616

17-
for (const file of files) {
17+
const promises = files.map(file => {
1818
const sourcePath = join(srcDir, file);
1919
const targetPath = join(targetDir, file);
2020

2121
const tStat = statSync(targetPath, { throwIfNoEntry: false });
2222

2323
if (tStat === undefined) {
24-
await copyFile(sourcePath, targetPath, constants.COPYFILE_FICLONE);
25-
continue;
24+
return copyFile(sourcePath, targetPath, constants.COPYFILE_FICLONE);
2625
}
2726

2827
const sStat = statSync(sourcePath);
2928

3029
if (sStat.size !== tStat.size || sStat.mtimeMs > tStat.mtimeMs) {
31-
await copyFile(sourcePath, targetPath, constants.COPYFILE_FICLONE);
30+
return copyFile(sourcePath, targetPath, constants.COPYFILE_FICLONE);
3231
}
33-
}
32+
});
33+
34+
await Promise.all(promises);
3435
}

0 commit comments

Comments
 (0)