1
0
forked from Isma/mods

Update manifest

This commit is contained in:
srgooglo 2023-11-02 17:44:48 +01:00
parent a902c1606b
commit 0540d2e3c6

View File

@ -1,9 +1,9 @@
// This variables can be changed :) // This variables can be changed :)
global._ = { global._ = {
pack_id: "mccom2023-dev", pack_id: "mccom2023",
version: "1.2.0", version: "1.3.0",
author: "MCommunity", author: "MCommunity",
name: "MCommunity DEV", name: "MCommunity",
description: "MCommunity official modpack.", description: "MCommunity official modpack.",
icon: "https://storage.ragestudio.net/gose-uploads/mccom/MCx128.png", icon: "https://storage.ragestudio.net/gose-uploads/mccom/MCx128.png",
@ -56,12 +56,14 @@ function resolveMcPath() {
return minecraftGameFolder return minecraftGameFolder
} }
function resolveMinecraftLauncher(args) { function resolveMinecraftLauncher(args, cwd) {
let _path = null let _path = null
console.log(os.type())
switch (os.type()) { switch (os.type()) {
case "win32": { case "Windows_NT": {
_path = `%ProgramFiles(x86)%\Minecraft Launcher\MinecraftLauncher.exe` _path = path.resolve(cwd, "runwin.bat")
break break
} }
case "Darwin": { case "Darwin": {
@ -73,7 +75,7 @@ function resolveMinecraftLauncher(args) {
} }
} }
if (_path && Array.isArray(args)) { if (_path && Array.isArray(args) && os.type() !== "Windows_NT") {
_path = [_path, ...args].join(" ") _path = [_path, ...args].join(" ")
} }
@ -179,6 +181,15 @@ module.exports = {
} }
fs.writeFileSync(profilesFilePath, JSON.stringify(profiles_json, null, 2)) fs.writeFileSync(profilesFilePath, JSON.stringify(profiles_json, null, 2))
if (os.type() === "Windows_NT") {
const runwinBat = path.resolve(pack_dir, "runwin.bat")
fs.writeFileSync(runwinBat, `
@echo off
cd "%ProgramFiles(x86)%/Minecraft Launcher"
start MinecraftLauncher.exe --workDir "${pack_dir}"
`, { encoding: 'utf8' })
}
}, },
uninstall: async ({ manifest, pack_dir, tmp_dir, spinner }) => { uninstall: async ({ manifest, pack_dir, tmp_dir, spinner }) => {
const minecraftGameFolder = resolveMcPath() const minecraftGameFolder = resolveMcPath()
@ -196,14 +207,22 @@ module.exports = {
} }
}, },
execute: async ({ manifest, pack_dir, tmp_dir, spinner }) => { execute: async ({ manifest, pack_dir, tmp_dir, spinner }) => {
const launcherBin = resolveMinecraftLauncher([ const launcherBin = resolveMinecraftLauncher([`--workDir ${pack_dir}`], os.type() === "Windows_NT" ? pack_dir : undefined)
`--workDir ${pack_dir}`,
])
console.log(launcherBin) console.log(launcherBin)
if (launcherBin) { if (!launcherBin) {
await child_process.exec(launcherBin) throw new Error("Minecraft Launcher binary not found")
} }
await new Promise((resolve, reject) => {
const process = child_process.execFile(launcherBin, [], {
shell: true,
})
process.on("exit", resolve)
process.on("error", reject)
})
} }
} }