You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
|
const fs = require('fs-extra');
|
|
|
|
|
|
const path = require('path');
|
|
|
|
|
|
|
|
|
|
|
|
const copyItems = [
|
|
|
|
|
|
'api',
|
|
|
|
|
|
'config',
|
|
|
|
|
|
'core',
|
|
|
|
|
|
'helper',
|
|
|
|
|
|
'middleware',
|
|
|
|
|
|
'models',
|
|
|
|
|
|
'services',
|
|
|
|
|
|
'utils',
|
|
|
|
|
|
'index.js',
|
|
|
|
|
|
'server.js'
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
// 目标目录(dist)
|
|
|
|
|
|
const distPath = path.resolve(__dirname, 'dist');
|
|
|
|
|
|
|
|
|
|
|
|
async function copyFiles() {
|
|
|
|
|
|
try {
|
|
|
|
|
|
// 确保dist目录存在
|
|
|
|
|
|
await fs.ensureDir(distPath);
|
|
|
|
|
|
|
|
|
|
|
|
// 遍历并复制每一项
|
|
|
|
|
|
for (const item of copyItems) {
|
|
|
|
|
|
const srcPath = path.resolve(__dirname, item);
|
|
|
|
|
|
const destPath = path.join(distPath, path.basename(item));
|
|
|
|
|
|
|
|
|
|
|
|
if (await fs.pathExists(srcPath)) {
|
|
|
|
|
|
await fs.copy(srcPath, destPath, { overwrite: true });
|
|
|
|
|
|
console.log(`✅ 已复制: ${item} → ${destPath}`);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
console.warn(`⚠️ 路径不存在: ${srcPath}`);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
console.log('🎉 所有文件复制完成!');
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
console.error('❌ 复制失败:', err);
|
|
|
|
|
|
process.exit(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
copyFiles();
|