refactor:优化

This commit is contained in:
Tianpao
2025-07-09 19:15:59 +08:00
parent 1e35fac53b
commit 2f518e4487

View File

@@ -54,12 +54,13 @@ async function main(modpack_path: string) {
yauzl.open(modpack_path, { lazyEntries: true }, (err, zipfile) => {
zipfile.readEntry(); //首次读取
zipfile.on("entry", async (entry) => {
if (/\/$/.test(entry.fileName)) {
} else if (entry.fileName.includes("overrides/")) {
const name: string = entry.fileName;
if (/\/$/.test(name)) {
} else if (name.includes("overrides/")) {
const zipfilex = join(
unzip_path,
zipname,
entry.fileName.replace("overrides/", "")
name.replace("overrides/", "")
);
if (!fs.existsSync(zipfilex)) {
zipfile.openReadStream(entry, (err, stream) => {
@@ -69,18 +70,14 @@ async function main(modpack_path: string) {
console.log(zipfilex);
stream.pipe(fse.createWriteStream(zipfilex));
});
//console.log(entry.fileName)
}
} else {
const name: string = entry.fileName;
} else if (name.endsWith(".json")||name.includes("mcbbs.packmeta")) {
dud_files.push(name);
if (name.endsWith(".json")) {
//console.log((await readzipentry(zipfile, entry)))
pack_info = JSON.parse(
(await readzipentry(zipfile, entry)).toString()
);
}
}
zipfile.readEntry();
});
zipfile.on("end", async () => {
@@ -93,7 +90,7 @@ async function main(modpack_path: string) {
await install(info.loader, info.minecraft, info.loader_version, dirx);
fs.writeFileSync(
join(dirx, "instance.zip"),
"#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://aka.ms/MinecraftEULA).\n#This serverpack created by DeEarthX\neula=true"
"#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://aka.ms/MinecraftEULA).\n#This serverpack created by DeEarthX(QQ_Group:559349662)\neula=true"
);
LOGGER.info("DeEarthX已将服务端制作完成");
zipfile.close();