(src: string, dest: string, ensureDir: (dirPath: string) => void)
| 106 | * 递归复制目录 |
| 107 | */ |
| 108 | export function copyDirRecursive(src: string, dest: string, ensureDir: (dirPath: string) => void): void { |
| 109 | ensureDir(dest) |
| 110 | const entries = fs.readdirSync(src, { withFileTypes: true }) |
| 111 | |
| 112 | for (const entry of entries) { |
| 113 | const srcPath = path.join(src, entry.name) |
| 114 | const destPath = path.join(dest, entry.name) |
| 115 | |
| 116 | if (entry.isDirectory()) { |
| 117 | copyDirRecursive(srcPath, destPath, ensureDir) |
| 118 | } else { |
| 119 | fs.copyFileSync(srcPath, destPath) |
| 120 | } |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | export interface CopyStats { |
| 125 | copied: number |
no test coverage detected