perf:WAI 拷贝前清理目录

main
LiaoYijun 7 months ago
parent a0ea74f81f
commit b97c8e449c

@ -21,6 +21,9 @@ async function copyFiles() {
try { try {
// 确保dist目录存在 // 确保dist目录存在
await fs.ensureDir(distPath); await fs.ensureDir(distPath);
// 清空dist目录中的所有内容
await fs.emptyDir(distPath);
console.log('🧹 ', distPath);
// 遍历并复制每一项 // 遍历并复制每一项
for (const item of copyItems) { for (const item of copyItems) {
@ -29,14 +32,14 @@ async function copyFiles() {
if (await fs.pathExists(srcPath)) { if (await fs.pathExists(srcPath)) {
await fs.copy(srcPath, destPath, { overwrite: true }); await fs.copy(srcPath, destPath, { overwrite: true });
console.log(`已复制: ${item}${destPath}`); console.log(`${item}${destPath}`);
} else { } else {
console.warn(`⚠️ 路径不存在: ${srcPath}`); console.warn(`⚠️ ${srcPath}`);
} }
} }
console.log('🎉 所有文件复制完成!'); console.log('🎉 Done');
} catch (err) { } catch (err) {
console.error('❌ 复制失败:', err); console.error('❌ ', err);
process.exit(1); process.exit(1);
} }
} }

Loading…
Cancel
Save