From 59d3744f56044317b83929f773a60b9b7a78bb5e Mon Sep 17 00:00:00 2001 From: Daniel Scalzi Date: Sat, 5 Sep 2020 00:01:36 -0400 Subject: [PATCH] Sort forgemods by file name to control load order. --- src/model/struct/model/module/forgemod.struct.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/model/struct/model/module/forgemod.struct.ts b/src/model/struct/model/module/forgemod.struct.ts index aa0d214..b5e3a05 100644 --- a/src/model/struct/model/module/forgemod.struct.ts +++ b/src/model/struct/model/module/forgemod.struct.ts @@ -1,5 +1,5 @@ import { Stats } from 'fs-extra' -import { Type } from 'helios-distribution-types' +import { Type, Module } from 'helios-distribution-types' import { join } from 'path' import { resolve } from 'url' import { VersionSegmented } from '../../../../util/VersionSegmented' @@ -21,6 +21,15 @@ export abstract class BaseForgeModStructure extends ToggleableModuleStructure im super(absoluteRoot, relativeRoot, 'forgemods', baseUrl, minecraftVersion, Type.ForgeMod) } + public async getSpecModel(): Promise { + // Sort by file name to allow control of load order. + return (await super.getSpecModel()).sort((a, b) => { + const aFileName = a.artifact.url.substring(a.artifact.url.lastIndexOf('/')+1) + const bFileName = b.artifact.url.substring(b.artifact.url.lastIndexOf('/')+1) + return aFileName.localeCompare(bFileName) + }) + } + public abstract isForVersion(version: MinecraftVersion, libraryVersion: string): boolean // eslint-disable-next-line @typescript-eslint/no-unused-vars