copy-decoder-files.js 799 B

123456789101112131415161718192021222324252627282930
  1. const fs = require('fs');
  2. const path = require('path');
  3. // 源文件路径
  4. const sourceDir = path.join(__dirname, 'src/assets/jessibuca');
  5. // 目标路径
  6. const targetDir = path.join(__dirname, 'public');
  7. // 确保目标目录存在
  8. if (!fs.existsSync(targetDir)) {
  9. fs.mkdirSync(targetDir, { recursive: true });
  10. }
  11. // 要复制的文件
  12. const filesToCopy = ['decoder.js', 'decoder.wasm'];
  13. // 复制文件
  14. filesToCopy.forEach(file => {
  15. const sourcePath = path.join(sourceDir, file);
  16. const targetPath = path.join(targetDir, file);
  17. if (fs.existsSync(sourcePath)) {
  18. fs.copyFileSync(sourcePath, targetPath);
  19. console.log(`已复制 ${file} 到 public 目录`);
  20. } else {
  21. console.error(`源文件 ${sourcePath} 不存在`);
  22. }
  23. });
  24. console.log('解码器文件复制完成!');