restore.js 509 B

12345678910111213141516
  1. const path = require('path');
  2. const fs = require('fs');
  3. // 获取当前命令行上下文路径
  4. const currentDirectory = process.cwd();
  5. // 获取缓存文件
  6. const cacheJsonPath = path.join(currentDirectory, 'scripts/cache.json');
  7. const cacheJsonContent = fs.readFileSync(cacheJsonPath, 'utf8');
  8. // 恢复配置文件
  9. const indexJsonPath = path.join(currentDirectory, 'src/config/index.json');
  10. fs.writeFileSync(indexJsonPath, cacheJsonContent, 'utf8');
  11. // 删除缓存文件
  12. fs.unlinkSync(cacheJsonPath);