refactor(zip): 优化代码结构和功能

- 引入 console.log 用于日志输出
- 修复 JSON 解析逻辑
- 移除未使用的变量和注释
This commit is contained in:
aixianling
2024-12-19 13:00:27 +08:00
parent 9f9f874610
commit a2d4283733

5
zip.js
View File

@@ -1,6 +1,7 @@
const fs = require("fs");
const path = require('path');
const JSZip = require("jszip");
const { log } = require("console");
const folderPath = "./configs"
const start = () => {
const files = fs.readdirSync(folderPath);
@@ -11,11 +12,9 @@ const start = () => {
// 并行读取所有的 JSON 文件内容
const combinedJson = {}
const jsonContents = jsonFiles.forEach(file => {
const fileData = fs.readFileSync(path.join(folderPath, file), 'utf8')
const fileData = JSON.parse(fs.readFileSync(path.join(folderPath, file), 'utf8'))
combinedJson[path.basename(file, '.json')] = fileData
});
// 将所有 JSON 文件的内容压缩为config.xml
compress(JSON.stringify(combinedJson, null, 2))
}
const compress = json => {