From 5f52230b4c19aa83c7b5fb8e0081850772d71a17 Mon Sep 17 00:00:00 2001 From: Big-Iron-Cheems <52252627+Big-Iron-Cheems@users.noreply.github.com> Date: Thu, 6 Nov 2025 20:09:17 +0100 Subject: [PATCH] Fix GitHub Actions mc version property read --- .github/builds/mc_version.js | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/.github/builds/mc_version.js b/.github/builds/mc_version.js index 6d75b9db42..225fac3416 100644 --- a/.github/builds/mc_version.js +++ b/.github/builds/mc_version.js @@ -4,27 +4,22 @@ */ import * as fs from "fs" -import * as readline from "readline" +import * as path from "path" +import {fileURLToPath} from "url" -export async function getMcVersion() { - let lines = readline.createInterface({ - input: fs.createReadStream("../../gradle.properties"), - crlfDelay: Infinity - }) +const __dirname = path.dirname(fileURLToPath(import.meta.url)) - let mcVersion = "" +export async function getMcVersion() { + const filePath = path.resolve(__dirname, "../../gradle/libs.versions.toml") - for await (const line of lines) { - if (line.startsWith("minecraft_version")) { - mcVersion = line.substring(line.indexOf("=") + 1) - break - } + if (!fs.existsSync(filePath)) { + throw new Error(`File not found: ${filePath}`) } - if (mcVersion === "") { - console.log("Failed to read minecraft_version") - process.exit(1) - } + const content = await fs.promises.readFile(filePath, "utf-8") + + const match = content.match(/^\s*minecraft\s*=\s*["']([^"']+)["']\s*$/m) + if (match) return match[1].trim() - return mcVersion + throw new Error(`Failed to find minecraft version in ${filePath}`) }