fix:修复modrinth json读取失败
This commit is contained in:
@@ -69,6 +69,7 @@ async function main(modpack_path: string) {
|
||||
const name: string = entry.fileName;
|
||||
dud_files.push(name);
|
||||
if (name.endsWith(".json")) {
|
||||
//console.log((await readzipentry(zipfile, entry)))
|
||||
pack_info = JSON.parse(
|
||||
(await readzipentry(zipfile, entry)).toString()
|
||||
);
|
||||
|
||||
@@ -8,14 +8,16 @@ import { MultiBar } from "cli-progress";
|
||||
import {URL, fileURLToPath } from "node:url";
|
||||
import { LOGGER } from "./logger.js";
|
||||
|
||||
export async function readzipentry(zipfile: yauzl.ZipFile, entry: yauzl.Entry):Promise<string|Buffer> {
|
||||
export async function readzipentry(zipfile: yauzl.ZipFile, entry: yauzl.Entry):Promise<string> {
|
||||
const data: Buffer<ArrayBufferLike>[] = [];
|
||||
return await new Promise((reslove, reject) => {
|
||||
zipfile.openReadStream(entry, (err, e) => {
|
||||
e.on("data", (chunk: Buffer) => {
|
||||
data.push(chunk);
|
||||
}).on("end", () => {
|
||||
reslove(data.toString());
|
||||
if (data.length !== 0&&typeof data !== "string"){
|
||||
reslove(Buffer.concat(data).toString());
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user