This commit is contained in:
61
copyEnvBuild.ts
Normal file
61
copyEnvBuild.ts
Normal file
@ -0,0 +1,61 @@
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
function copyDirRecursive(source: string, target: string) {
|
||||
// 创建目标目录
|
||||
if (!fs.existsSync(target)) {
|
||||
fs.mkdirSync(target, { recursive: true });
|
||||
}
|
||||
|
||||
// 读取源目录内容
|
||||
const files = fs.readdirSync(source);
|
||||
|
||||
for (const file of files) {
|
||||
const sourcePath = path.join(source, file);
|
||||
const targetPath = path.join(target, file);
|
||||
|
||||
const stat = fs.statSync(sourcePath);
|
||||
|
||||
if (stat.isDirectory()) {
|
||||
// 如果是目录,递归复制
|
||||
copyDirRecursive(sourcePath, targetPath);
|
||||
} else {
|
||||
// 如果是文件,复制文件
|
||||
fs.copyFileSync(sourcePath, targetPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function copyMathJax() {
|
||||
const sourceDir = path.join(process.cwd(), 'node_modules', 'mathjax-full');
|
||||
const targetDir = path.join(process.cwd(), 'build', 'client', 'node_modules', 'mathjax-full');
|
||||
|
||||
console.log('开始复制 MathJax...');
|
||||
console.log('源目录:', sourceDir);
|
||||
console.log('目标目录:', targetDir);
|
||||
|
||||
try {
|
||||
// 检查源目录是否存在
|
||||
if (!fs.existsSync(sourceDir)) {
|
||||
console.error('错误: mathjax-full 目录不存在,请先安装 mathjax-full');
|
||||
console.log('运行: npm install mathjax-full');
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果目标目录已存在,就退出
|
||||
if (fs.existsSync(targetDir)) {
|
||||
console.log('目标目录已存在,跳过复制');
|
||||
return;
|
||||
}
|
||||
|
||||
// 复制目录
|
||||
copyDirRecursive(sourceDir, targetDir);
|
||||
console.log('✅ MathJax 复制完成!');
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ 复制过程中发生错误:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// 运行复制函数
|
||||
copyMathJax();
|
||||
Reference in New Issue
Block a user