Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/installers/InstallRulePluginInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ async function uninstallSubDir(mod: ManifestV2, profile: ImmutableProfile) {
}
}

async function uninstallState(mod: ManifestV2, profile: ImmutableProfile) {
export async function uninstallState(mod: ManifestV2, profile: ImmutableProfile): Promise<void> {
const stateFilePath = profile.joinToProfilePath("_state", `${mod.getName()}-state.yml`);
if (await FsProvider.instance.exists(stateFilePath)) {
const read = await FsProvider.instance.readFile(stateFilePath);
Expand Down Expand Up @@ -342,7 +342,7 @@ async function applyModeSubDirs(mod: ManifestV2, profile: ImmutableProfile, mode
}

// Enables or disables a mod installed with InstallRulePluginInstaller using STATE tracking method.
async function applyModeState(mod: ManifestV2, profile: ImmutableProfile, mode: number): Promise<void> {
export async function applyModeState(mod: ManifestV2, profile: ImmutableProfile, mode: number): Promise<void> {
const modStateFilePath = profile.joinToProfilePath("_state", `${mod.getName()}-state.yml`);
if (await FsProvider.instance.exists(modStateFilePath)) {
const fileContents = (await FsProvider.instance.readFile(modStateFilePath)).toString();
Expand Down
15 changes: 14 additions & 1 deletion src/installers/LovelyInstaller.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { InstallArgs, PackageInstaller, uninstallModLoader } from "./PackageInstaller";
import { addToStateFile } from "./InstallRulePluginInstaller";
import { addToStateFile, applyModeState, uninstallState } from "./InstallRulePluginInstaller";
import FsProvider from "../providers/generic/file/FsProvider";
import FileUtils from "../utils/FileUtils";
import FileTree from "../model/file/FileTree";
import ModMode from "../model/enums/ModMode";
import R2Error from "../model/errors/R2Error";
import path from "../providers/node/path/path";

Expand Down Expand Up @@ -79,4 +80,16 @@ export class LovelyPluginInstaller implements PackageInstaller {

await addToStateFile(mod, fileRelocations, profile);
}

async uninstall(args: InstallArgs) {
await uninstallState(args.mod, args.profile);
}

async enable(args: InstallArgs) {
await applyModeState(args.mod, args.profile, ModMode.ENABLED);
}

async disable(args: InstallArgs) {
await applyModeState(args.mod, args.profile, ModMode.DISABLED);
}
}
Loading