potentially gather installed mods

This commit is contained in:
SpikeHD
2022-07-24 00:24:10 -07:00
parent a25645ef77
commit 811f437238
4 changed files with 115 additions and 7 deletions

View File

@@ -1,4 +1,5 @@
import { invoke } from '@tauri-apps/api'
import { getConfigOption } from './configuration'
// Generated with https://transform.tools/json-to-typescript I'm lazy cry about it
export interface GamebananaResponse {
@@ -115,3 +116,21 @@ export async function formatGamebananaData(obj: GamebananaResponse[]) {
})
.filter((itm) => itm.type === 'Mod')
}
export async function getInstalledMods() {
const migotoPath = await getConfigOption('migoto_path')
if (!migotoPath) return []
const mods = (await invoke('list_mods', {
path: migotoPath,
})) as Record<string, string>
// These are returned as JSON strings, so we have to parse them
return Object.keys(mods).map((path) => {
return {
path,
info: JSON.parse(mods[path]),
}
})
}