Skip to content

Commit

Permalink
Sort forgemods by file name to control load order.
Browse files Browse the repository at this point in the history
  • Loading branch information
dscalzi committed Sep 5, 2020
1 parent d2e317b commit 59d3744
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/model/struct/model/module/forgemod.struct.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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
Expand Down

0 comments on commit 59d3744

Please sign in to comment.