Sort forgemods by file name to control load order.

This commit is contained in:
Daniel Scalzi
2020-09-05 00:01:36 -04:00
parent d2e317b4df
commit 59d3744f56

View File

@@ -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<Module[]> {
// 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