diff --git a/tests/modrinth-java.test.ts.template b/tests/modrinth-java.test.ts.template index add2bc0..8cf75ad 100644 --- a/tests/modrinth-java.test.ts.template +++ b/tests/modrinth-java.test.ts.template @@ -1,5 +1,11 @@ import { test } from "vitest"; -import { Instance, offlineAuth, RuntimeManager, getJavaComponent, importModrinthModpack } from "../../dist/index.js"; +import { + Instance, + offlineAuth, + RuntimeManager, + getJavaComponent, + importModrinthModpack, +} from "../../dist/index.js"; import path from "path"; import fs from "fs/promises"; @@ -8,23 +14,29 @@ const gameRoot = path.join(import.meta.dirname, "..", "temp"); // await fs.mkdir(gameRoot, { recursive: true }); test("launch game", { timeout: 0, tags: ["modrinth"] }, async () => { + const modpack = await importModrinthModpack( + "${modpack_url}", + ); + const javaManager = new RuntimeManager(path.join(gameRoot, "java")); - javaManager.on("progress", console.log) - // const java = await javaManager.use(await getJavaComponent("${version}")) + javaManager.on("progress", console.log); + // const java = await javaManager.use(await getJavaComponent("${version}")); const instance = new Instance({ auth: offlineAuth("player"), - paths: { root: gameRoot, instance: path.join(gameRoot, "instances", "${modpack_id}") }, + paths: { + root: gameRoot, + instance: path.join(gameRoot, "instances", "${modpack_id}"), + }, javaExecutable: "${java}", - ram: { max: "4G", min: "4G" } - }, - await importModrinthModpack("${modpack_url}", "url") - ); + ram: { max: "4G", min: "4G" }, + modrinth: modpack, + }); instance.on("progress", console.log); instance.on("log", (step, msg) => { - console.log(`[${step}] ${msg}`) - }) + console.log(`[${step}] ${msg}`); + }); await instance.install(); const p = await instance.launch(); diff --git a/tests/modrinth.test.ts.template b/tests/modrinth.test.ts.template index fe3a431..b3014fc 100644 --- a/tests/modrinth.test.ts.template +++ b/tests/modrinth.test.ts.template @@ -8,46 +8,49 @@ const gameRoot = path.join(import.meta.dirname, "..", "temp"); // await fs.mkdir(gameRoot, { recursive: true }); test("launch game", { timeout: 0, tags: ["modrinth"] }, async () => { - const javaManager = new RuntimeManager(path.join(gameRoot, "java")); - javaManager.on("progress", console.log) - const modpack = - await importModrinthModpack("${modpack_url}", "url") - const java = await javaManager.use(await getJavaComponent(modpack.version)) - - - const instance = new Instance({ - auth: offlineAuth("player"), - paths: { root: gameRoot, instance: path.join(gameRoot, "instances", "${modpack_id}") }, - javaExecutable: java, - ram: { max: "4G", min: "4G" } - }, - modpack - ); - - instance.on("progress", console.log); - instance.on("log", (step, msg) => { - console.log(`[${step}] ${msg}`) - }) - - await instance.install(); - const p = await instance.launch(); - - p.stdout.on("data", (d: Buffer) => { - console.log(d.toString()); - }); - - p.stderr.on("data", (d: Buffer) => { - console.log(d.toString()); - }); - - await new Promise((res) => { - p.on("error", (d: Buffer) => { + const modpack = await importModrinthModpack( + "${modpack_url}", + ); + + const javaManager = new RuntimeManager(path.join(gameRoot, "java")); + javaManager.on("progress", console.log); + const java = await javaManager.use(await getJavaComponent("${version}")); + + const instance = new Instance({ + auth: offlineAuth("player"), + paths: { + root: gameRoot, + instance: path.join(gameRoot, "instances", "${modpack_id}"), + }, + javaExecutable: java, + ram: { max: "4G", min: "4G" }, + modrinth: modpack, + }); + + instance.on("progress", console.log); + instance.on("log", (step, msg) => { + console.log(`[${step}] ${msg}`); + }); + + await instance.install(); + const p = await instance.launch(); + + p.stdout.on("data", (d: Buffer) => { console.log(d.toString()); - res(); }); - p.on("close", () => { - console.log("closed"); - res(); + + p.stderr.on("data", (d: Buffer) => { + console.log(d.toString()); + }); + + await new Promise((res) => { + p.on("error", (d: Buffer) => { + console.log(d.toString()); + res(); + }); + p.on("close", () => { + console.log("closed"); + res(); + }); }); - }); });