Skip to content
Open
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: 3 additions & 1 deletion extensions/gamebryo-plugin-management/src/autosort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { gameDataPath, gameSupported, nativePlugins, pluginPath } from "./util/g
import { missingGroupFixes } from "./util/groups";
import { invalidPluginsFromError } from "./util/invalidPlugins";
import { downloadMasterlist, downloadPrelude } from "./util/masterlist";
import toLootPluginName from "./util/toLootPluginName";
import toPluginId from "./util/toPluginId";

const MAX_RESTARTS = 3;
Expand Down Expand Up @@ -578,7 +579,7 @@ class LootInterface {
}
try {
await loot.loadPluginsAsync(
deployed.filter((id) => !invalid.has(id)).map((name) => toPluginId(name)),
deployed.filter((id) => !invalid.has(id)).map((id) => toLootPluginName(id, pluginList)),
false,
);
pluginsLoaded = true;
Expand Down Expand Up @@ -908,6 +909,7 @@ class LootInterface {
expectSuccess: true,
env: {
ELECTRON_RUN_AS_NODE: "1",
LD_LIBRARY_PATH: path.join(__dirname, ".."),
},
})
.catch((err: Error) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { describe, expect, it } from "vitest";

import toLootPluginName from "./toLootPluginName";

describe("toLootPluginName", () => {
it("uses on-disk filename casing when file path is known", () => {
const pluginList = {
"myplugin.esp": {
filePath: "C:\\Games\\Data\\MyPlugin.esp",
},
} as any;

expect(toLootPluginName("myplugin.esp", pluginList)).toBe("MyPlugin.esp");
});

it("falls back to normalized plugin id when file path is missing", () => {
expect(toLootPluginName("MyPlugin.esp", {} as any)).toBe("myplugin.esp");
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as path from "path";

import { IPlugins } from "../types/IPlugins";
import toPluginId from "./toPluginId";

function toLootPluginName(pluginId: string, pluginList: IPlugins): string {
const filePath = pluginList[pluginId]?.filePath;
if (filePath === undefined) {
return toPluginId(pluginId);
}
const base = path.basename(filePath);
return base === filePath ? path.win32.basename(filePath) : base;
}

export default toLootPluginName;