(entry)
| 24 | } |
| 25 | |
| 26 | async function copyEntry(entry) { |
| 27 | const from = path.join(projectRoot, entry); |
| 28 | const to = path.join(distDir, entry); |
| 29 | if (!fs.existsSync(from)) { |
| 30 | console.warn(`⚠️ 跳过不存在的入口: ${entry}`); |
| 31 | return; |
| 32 | } |
| 33 | try { |
| 34 | const stats = await fs.promises.stat(from); |
| 35 | if (stats.isDirectory()) { |
| 36 | await copyDirectory(from, to); |
| 37 | } else { |
| 38 | await fs.promises.mkdir(path.dirname(to), { recursive: true }); |
| 39 | await fs.promises.copyFile(from, to); |
| 40 | } |
| 41 | } catch (err) { |
| 42 | console.error(`❌ 复制失败 ${entry}:`, err.message); |
| 43 | throw err; |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | async function copyDirectory(source, destination) { |
| 48 | try { |
no test coverage detected