Fix crash when finding version when mod manager is not initialised

This commit is contained in:
Kallum Jones 2022-08-11 23:28:22 +01:00
parent 562b43e0b0
commit 066a63f913
No known key found for this signature in database
GPG Key ID: D7F4589C4D7F81A9
2 changed files with 7 additions and 2 deletions

View File

@ -5,7 +5,7 @@ import Subcommand from "./subcommand.js";
export default class InitCommand implements Subcommand {
registerCommand(program: Command) {
program.command("init")
.description("Initialises mod manager")
.description("Initialises mod manager. Execute in the root of the server directory you want to use Mod Manager in")
.action(async () => {
await Initialiser.initialise();
});

View File

@ -18,6 +18,7 @@ import ModrinthSource from "./mods/sources/modrinth_source.js";
import Mods from "./mods/mods.js";
import {CurseforgeSource} from "./mods/sources/curseforge_source.js";
import MinecraftUtils from "./util/minecraft_utils.js";
import chalk from "chalk";
export default class ModManager {
public static logger: Logger | null = null;
@ -46,10 +47,14 @@ export default class ModManager {
this.logger = ModManager.createLogger();
}
const version = Initialiser.isInitialised() ?
await MinecraftUtils.getCurrentMinecraftVersion() :
chalk.redBright("Not Initialised. See `mod-manager init -h` for more details!")
this.program
.name('mod-manager')
.description('A package (mod) manager for Fabric Minecraft Servers')
.version(`Minecraft server version: ${await MinecraftUtils.getCurrentMinecraftVersion()}`, "-v, --version", "Reports the version of the Minecraft server");
.version(`Minecraft server version: ${version}`, "-v, --version", "Reports the version of the Minecraft server");
for (const command of this.subcommands) {