From a2d42837339fea1b9faf1ded8c3b80107a837d38 Mon Sep 17 00:00:00 2001 From: aixianling Date: Thu, 19 Dec 2024 13:00:27 +0800 Subject: [PATCH] =?UTF-8?q?refactor(zip):=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=BB=93=E6=9E=84=E5=92=8C=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 引入 console.log 用于日志输出 - 修复 JSON 解析逻辑 - 移除未使用的变量和注释 --- zip.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/zip.js b/zip.js index 293df4c..b479099 100644 --- a/zip.js +++ b/zip.js @@ -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 => {