Skip to content

Commit

Permalink
Merge branch 'bugfix/44-version-switch-fix'
Browse files Browse the repository at this point in the history
  • Loading branch information
maradotwebp committed Jul 18, 2021
1 parent 4068d5c commit 0992f2a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/cmd/version.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ proc paxVersion*(version: string, loader: string): void =
var manifest = readManifestFromDisk()
let loader = if loader == "": manifest.loader else: loader

let loaderId = waitFor(manifest.mcVersion.getMcModloaderId(loader))
let loaderId = waitFor(version.Version.getMcModloaderId(loader))
if loaderId.isNone:
echoError "This is either not a minecraft version, or no ", $loader, " version exists for this minecraft version."
quit(1)
return

manifest.mcVersion = version.Version
manifest.mcModloaderId = loaderId.get()
Expand Down
20 changes: 19 additions & 1 deletion tests/cmd/tversion.nim
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,22 @@ block: # switch mc version & loader
paxVersion("1.17.1", loader = "fabric")
let manifest = readFile("./modpack/manifest.json").parseJson
doAssert manifest["minecraft"]["version"].getStr() == "1.17.1"
doAssert manifest["minecraft"]["modLoaders"][0]["id"].getStr().startsWith("fabric")
doAssert manifest["minecraft"]["modLoaders"][0]["id"].getStr().startsWith("fabric")

block: # prevent invalid versions
removeDir("./modpack/")

createDir("./modpack")
writeFile("./modpack/manifest.json", manifestJson.pretty)

paxVersion("1.12.2")
var manifest = readFile("./modpack/manifest.json").parseJson
doAssert manifest["minecraft"]["version"].getStr() == "1.12.2"

paxVersion("10.11.12")
manifest = readFile("./modpack/manifest.json").parseJson
doAssert manifest["minecraft"]["version"].getStr() == "1.12.2"

paxVersion("1.16.100")
manifest = readFile("./modpack/manifest.json").parseJson
doAssert manifest["minecraft"]["version"].getStr() == "1.12.2"

0 comments on commit 0992f2a

Please sign in to comment.