49 lines
1.4 KiB
JavaScript
49 lines
1.4 KiB
JavaScript
const process = require("child_process");
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
// 构建发布
|
|
try {
|
|
const output = process.execSync('npm run tsrpc-build');
|
|
console.log("构建结束",output.toString());
|
|
} catch (error) {
|
|
console.error('Error executing command:', error);
|
|
}
|
|
// process.execSync('npm run tsrpc-build');
|
|
// console.log("构建完成")
|
|
// 复制配置文件
|
|
fs.copyFileSync("./ecosystem.config.js", "./dist/ecosystem.config.js")
|
|
fs.copyFileSync("./Dockerfile", "./dist/Dockerfile")
|
|
// console.log("文件复制完成")const { execSync } = require('child_process');
|
|
// 复制文件
|
|
function copyFile(src, dest) {
|
|
fs.copyFileSync(src, dest);
|
|
}
|
|
|
|
// 递归复制文件夹
|
|
function copyFolder(src, dest) {
|
|
// 如果目标文件夹不存在,创建它
|
|
if (!fs.existsSync(dest)) {
|
|
fs.mkdirSync(dest, { recursive: true });
|
|
}
|
|
|
|
// 读取源文件夹中的文件和子目录
|
|
const items = fs.readdirSync(src);
|
|
|
|
items.forEach(item => {
|
|
const srcItem = path.join(src, item);
|
|
const destItem = path.join(dest, item);
|
|
|
|
const stat = fs.statSync(srcItem);
|
|
|
|
// 如果是文件,则直接复制
|
|
if (stat.isFile()) {
|
|
copyFile(srcItem, destItem);
|
|
}
|
|
// 如果是文件夹,则递归调用
|
|
else if (stat.isDirectory()) {
|
|
copyFolder(srcItem, destItem);
|
|
}
|
|
});
|
|
}
|
|
|
|
copyFolder("./src/shared/configs/data/", "./dist/shared/configs/data/") |