diff --git a/src/loaders/neoforge/neoforge-metadata-reader.ts b/src/loaders/neoforge/neoforge-metadata-reader.ts index d3d8670..167c512 100644 --- a/src/loaders/neoforge/neoforge-metadata-reader.ts +++ b/src/loaders/neoforge/neoforge-metadata-reader.ts @@ -4,7 +4,7 @@ import { readAllZippedText } from "@/utils/io/file-info"; import { LoaderType } from "../loader-type"; import { LoaderMetadataReader } from "../loader-metadata-reader"; import { NeoForgeMetadata } from "./neoforge-metadata"; -import { MODS_TOML } from "./raw-neoforge-metadata"; +import { NEOFORGE_MODS_TOML, MODS_TOML } from "./raw-neoforge-metadata"; /** * A metadata reader that is able to read NeoForge mod metadata from a zipped file. @@ -14,7 +14,10 @@ export class NeoForgeMetadataReader implements LoaderMetadataReader { - const metadataText = await readAllZippedText(path, MODS_TOML); + // Prefer `neoforge.mods.toml` over `mods.toml`. + const metadataText = await readAllZippedText(path, NEOFORGE_MODS_TOML) + .catch(() => readAllZippedText(path, MODS_TOML)); + const metadata = NeoForgeMetadata.from(parseToml(metadataText)); if (!metadata.dependencies.some(x => x.id === LoaderType.NEOFORGE)) { throw new Error("A NeoForge metadata file must contain a 'neoforge' dependency"); diff --git a/src/loaders/neoforge/raw-neoforge-metadata.ts b/src/loaders/neoforge/raw-neoforge-metadata.ts index 5359ed6..244885e 100644 --- a/src/loaders/neoforge/raw-neoforge-metadata.ts +++ b/src/loaders/neoforge/raw-neoforge-metadata.ts @@ -73,3 +73,8 @@ export interface RawNeoForgeMetadata { * Name of the `mods.toml` file, that contains raw NeoForge metadata. */ export const MODS_TOML = "META-INF/mods.toml"; + +/** + * Name of the `neoforge.mods.toml` file, that contains raw NeoForge metadata. + */ +export const NEOFORGE_MODS_TOML = "META-INF/neoforge.mods.toml"; diff --git a/tests/content/neoforge/mods.toml b/tests/content/neoforge/neoforge.mods.toml similarity index 100% rename from tests/content/neoforge/mods.toml rename to tests/content/neoforge/neoforge.mods.toml diff --git a/tests/unit/loaders/loader-metadata-reader.spec.ts b/tests/unit/loaders/loader-metadata-reader.spec.ts index f86954b..f52e3c6 100644 --- a/tests/unit/loaders/loader-metadata-reader.spec.ts +++ b/tests/unit/loaders/loader-metadata-reader.spec.ts @@ -13,7 +13,8 @@ beforeEach(async () => { "fabric.jar": await zipFile([__dirname, "../../content/fabric/fabric.mod.json"]), "quilt.jar": await zipFile([__dirname, "../../content/quilt/quilt.mod.json"]), "forge.jar": await zipFile([__dirname, "../../content/forge/mods.toml"], "META-INF/mods.toml"), - "neoforge.jar": await zipFile([__dirname, "../../content/neoforge/mods.toml"], "META-INF/mods.toml"), + "neoforge.jar": await zipFile([__dirname, "../../content/neoforge/neoforge.mods.toml"], "META-INF/neoforge.mods.toml"), + "neoforge.legacy.jar": await zipFile([__dirname, "../../content/neoforge/neoforge.mods.toml"], "META-INF/mods.toml"), "text.txt": "", }); }); diff --git a/tests/unit/loaders/neoforge/neoforge-metadata-reader.spec.ts b/tests/unit/loaders/neoforge/neoforge-metadata-reader.spec.ts index fd9252b..f884be2 100644 --- a/tests/unit/loaders/neoforge/neoforge-metadata-reader.spec.ts +++ b/tests/unit/loaders/neoforge/neoforge-metadata-reader.spec.ts @@ -5,7 +5,7 @@ import { NeoForgeMetadataReader } from "@/loaders/neoforge/neoforge-metadata-rea beforeEach(async () => { mockFs({ - "neoforge.mod.jar": await zipFile([__dirname, "../../../content/neoforge/mods.toml"], "META-INF/mods.toml"), + "neoforge.mod.jar": await zipFile([__dirname, "../../../content/neoforge/neoforge.mods.toml"], "META-INF/neoforge.mods.toml"), "text.txt": "", }); }); @@ -15,7 +15,7 @@ afterEach(() => { }); describe("NeoForgeMetadataReader", () => { - test("successfully reads mods.toml", async () => { + test("successfully reads neoforge.mods.toml", async () => { const reader = new NeoForgeMetadataReader(); const metadata = await reader.readMetadataFile("neoforge.mod.jar"); diff --git a/tests/unit/loaders/neoforge/neoforge-metadata.spec.ts b/tests/unit/loaders/neoforge/neoforge-metadata.spec.ts index f64484b..1633a73 100644 --- a/tests/unit/loaders/neoforge/neoforge-metadata.spec.ts +++ b/tests/unit/loaders/neoforge/neoforge-metadata.spec.ts @@ -7,7 +7,7 @@ import { RawNeoForgeMetadata } from "@/loaders/neoforge/raw-neoforge-metadata"; import { NeoForgeMetadata } from "@/loaders/neoforge/neoforge-metadata"; const RAW_METADATA: RawNeoForgeMetadata = Object.freeze(parseToml( - readFileSync(resolvePath(__dirname, "../../../content/neoforge/mods.toml"), "utf8") + readFileSync(resolvePath(__dirname, "../../../content/neoforge/neoforge.mods.toml"), "utf8") )); describe("NeoForgeMetadata", () => {