(srcDir: string, destDir: string)
| 626 | // NOTE: we cannot use `fs.cpSync` because of a bug in Node.js (https://github.com/nodejs/node/issues/58768, https://github.com/nodejs/node/issues/59168) |
| 627 | // also note that we should set `dereference: true` when we use `fs.cpSync` |
| 628 | export function copyDir(srcDir: string, destDir: string): void { |
| 629 | fs.mkdirSync(destDir, { recursive: true }) |
| 630 | for (const file of fs.readdirSync(srcDir)) { |
| 631 | const srcFile = path.resolve(srcDir, file) |
| 632 | if (srcFile === destDir) { |
| 633 | continue |
| 634 | } |
| 635 | const destFile = path.resolve(destDir, file) |
| 636 | const stat = fs.statSync(srcFile) |
| 637 | if (stat.isDirectory()) { |
| 638 | copyDir(srcFile, destFile) |
| 639 | } else { |
| 640 | fs.copyFileSync(srcFile, destFile) |
| 641 | } |
| 642 | } |
| 643 | } |
| 644 | |
| 645 | export const ERR_SYMLINK_IN_RECURSIVE_READDIR = |
| 646 | 'ERR_SYMLINK_IN_RECURSIVE_READDIR' |
no test coverage detected