Skip to content

Commit 76519b6

Browse files
committed
fix: Windows build
1 parent 7cc01a6 commit 76519b6

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

src/bindings/utils/compileLLamaCpp.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -503,14 +503,29 @@ async function applyResultDirFixes(resultDirPath: string, tempDirPath: string) {
503503
}
504504

505505
async function mergeDirWithoutOverrides(sourceDirPath: string, targetDirPath: string) {
506-
const itemNames = await fs.readdir(sourceDirPath);
506+
const itemNames = await fs.readdir(sourceDirPath, {withFileTypes: true});
507507

508508
await Promise.all(
509-
itemNames.map((itemName) => (
510-
fs.move(path.join(sourceDirPath, itemName), path.join(targetDirPath, itemName), {
511-
overwrite: false
512-
})
513-
))
509+
itemNames.map(async (item) => {
510+
const targetItemPath = path.join(targetDirPath, item.name);
511+
512+
if (item.isDirectory()) {
513+
if (await fs.pathExists(targetItemPath)) {
514+
if ((await fs.stat(targetItemPath)).isDirectory())
515+
await mergeDirWithoutOverrides(path.join(sourceDirPath, item.name), targetItemPath);
516+
} else {
517+
await fs.ensureDir(targetItemPath);
518+
await mergeDirWithoutOverrides(path.join(sourceDirPath, item.name), targetItemPath);
519+
}
520+
} else {
521+
if (await fs.pathExists(targetItemPath))
522+
return;
523+
524+
await fs.move(path.join(sourceDirPath, item.name), targetItemPath, {
525+
overwrite: false
526+
});
527+
}
528+
})
514529
);
515530
}
516531

0 commit comments

Comments
 (0)