refactor(zip): 优化代码结构和功能
- 引入 console.log 用于日志输出 - 修复 JSON 解析逻辑 - 移除未使用的变量和注释
This commit is contained in:
5
zip.js
5
zip.js
@@ -1,6 +1,7 @@
|
|||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const JSZip = require("jszip");
|
const JSZip = require("jszip");
|
||||||
|
const { log } = require("console");
|
||||||
const folderPath = "./configs"
|
const folderPath = "./configs"
|
||||||
const start = () => {
|
const start = () => {
|
||||||
const files = fs.readdirSync(folderPath);
|
const files = fs.readdirSync(folderPath);
|
||||||
@@ -11,11 +12,9 @@ const start = () => {
|
|||||||
// 并行读取所有的 JSON 文件内容
|
// 并行读取所有的 JSON 文件内容
|
||||||
const combinedJson = {}
|
const combinedJson = {}
|
||||||
const jsonContents = jsonFiles.forEach(file => {
|
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
|
combinedJson[path.basename(file, '.json')] = fileData
|
||||||
});
|
});
|
||||||
|
|
||||||
// 将所有 JSON 文件的内容压缩为config.xml
|
|
||||||
compress(JSON.stringify(combinedJson, null, 2))
|
compress(JSON.stringify(combinedJson, null, 2))
|
||||||
}
|
}
|
||||||
const compress = json => {
|
const compress = json => {
|
||||||
|
|||||||
Reference in New Issue
Block a user