mirror of
https://git.bits.team/Bits/mod-manager.git
synced 2024-11-21 13:38:21 -05:00
Fix crash when finding version when mod manager is not initialised
This commit is contained in:
parent
562b43e0b0
commit
066a63f913
@ -5,7 +5,7 @@ import Subcommand from "./subcommand.js";
|
|||||||
export default class InitCommand implements Subcommand {
|
export default class InitCommand implements Subcommand {
|
||||||
registerCommand(program: Command) {
|
registerCommand(program: Command) {
|
||||||
program.command("init")
|
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 () => {
|
.action(async () => {
|
||||||
await Initialiser.initialise();
|
await Initialiser.initialise();
|
||||||
});
|
});
|
||||||
|
@ -18,6 +18,7 @@ import ModrinthSource from "./mods/sources/modrinth_source.js";
|
|||||||
import Mods from "./mods/mods.js";
|
import Mods from "./mods/mods.js";
|
||||||
import {CurseforgeSource} from "./mods/sources/curseforge_source.js";
|
import {CurseforgeSource} from "./mods/sources/curseforge_source.js";
|
||||||
import MinecraftUtils from "./util/minecraft_utils.js";
|
import MinecraftUtils from "./util/minecraft_utils.js";
|
||||||
|
import chalk from "chalk";
|
||||||
|
|
||||||
export default class ModManager {
|
export default class ModManager {
|
||||||
public static logger: Logger | null = null;
|
public static logger: Logger | null = null;
|
||||||
@ -46,10 +47,14 @@ export default class ModManager {
|
|||||||
this.logger = ModManager.createLogger();
|
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
|
this.program
|
||||||
.name('mod-manager')
|
.name('mod-manager')
|
||||||
.description('A package (mod) manager for Fabric Minecraft Servers')
|
.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) {
|
for (const command of this.subcommands) {
|
||||||
|
Loading…
Reference in New Issue
Block a user