39 lines
1.0 KiB
JavaScript
39 lines
1.0 KiB
JavaScript
const fs = require('fs');
|
|||
|
|
const path = require('path');
|
||
|
|
|
||
|
|
const cesiumSourcePath = path.join(__dirname, '../node_modules/cesium/Build/Cesium');
|
||
|
|
const cesiumDestPath = path.join(__dirname, '../public/cesium');
|
||
|
|
|
||
|
|
// 创建目标目录(如果不存在)
|
||
|
|
if (!fs.existsSync(cesiumDestPath)) {
|
||
|
|
fs.mkdirSync(cesiumDestPath, { recursive: true });
|
||
|
|
}
|
||
|
|
|
||
|
|
// 复制文件函数
|
||
|
|
function copyRecursiveSync(src, dest) {
|
||
|
|
const exists = fs.existsSync(src);
|
||
|
|
const stats = exists && fs.statSync(src);
|
||
|
|
const isDirectory = exists && stats.isDirectory();
|
||
|
|
|
||
|
|
if (isDirectory) {
|
||
|
|
fs.mkdirSync(dest, { recursive: true });
|
||
|
|
fs.readdirSync(src).forEach(childItemName => {
|
||
|
|
copyRecursiveSync(
|
||
|
|
path.join(src, childItemName),
|
||
|
|
path.join(dest, childItemName)
|
||
|
|
);
|
||
|
|
});
|
||
|
|
} else {
|
||
|
|
fs.copyFileSync(src, dest);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// 执行复制
|
||
|
|
try {
|
||
|
|
copyRecursiveSync(cesiumSourcePath, cesiumDestPath);
|
||
|
|
console.log('Cesium assets copied successfully!');
|
||
|
|
} catch (err) {
|
||
|
|
console.error('Error copying Cesium assets:', err);
|
||
|
|
process.exit(1);
|
||
|
|
}
|