Skip to content

Commit c6dd180

Browse files
committed
chore: more changes
1 parent d519966 commit c6dd180

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
@@ -1,6 +1,7 @@
11
'use strict';
22

3-
import { copyFile, readdir, stat } from 'node:fs/promises';
3+
import { statSync, constants } from 'node:fs';
4+
import { copyFile, readdir } from 'node:fs/promises';
45
import { join } from 'node:path';
56

67
/**
@@ -17,17 +18,17 @@ export async function safeCopy(srcDir, targetDir) {
1718
const sourcePath = join(srcDir, file);
1819
const targetPath = join(targetDir, file);
1920

20-
const tStat = await stat(targetPath).catch(() => undefined);
21+
const tStat = statSync(targetPath, { throwIfNoEntry: false });
2122

2223
if (tStat === undefined) {
23-
await copyFile(sourcePath, targetPath);
24+
await copyFile(sourcePath, targetPath, constants.COPYFILE_FICLONE);
2425
continue;
2526
}
2627

27-
const sStat = await stat(sourcePath);
28+
const sStat = statSync(sourcePath);
2829

2930
if (sStat.size !== tStat.size || sStat.mtimeMs > tStat.mtimeMs) {
30-
await copyFile(sourcePath, targetPath);
31+
await copyFile(sourcePath, targetPath, constants.COPYFILE_FICLONE);
3132
}
3233
}
3334
}

0 commit comments

Comments
 (0)