diff --git a/main.js b/main.js
index 4f014dc..3ee996c 100644
--- a/main.js
+++ b/main.js
@@ -9,6 +9,7 @@ const extract = require("extract-zip");
const store = new Store();
const userSavePath = app.getPath('userData')
let silksongPath = store.get('silksong-path')
+let bepinexVersion
const createWindow = () => {
const win = new BrowserWindow({
@@ -121,6 +122,7 @@ ipcMain.handle('install-bepinex', async () => {
}
const release = await res.json();
+ bepinexVersion = release.tag_name;
const asset = release.assets.find(
a => a.name.endsWith(".zip") && a.name.toLowerCase().includes("win_x64")
@@ -140,4 +142,29 @@ ipcMain.handle('install-bepinex', async () => {
await extract(filePath, { dir: silksongPath})
await fs.unlink(filePath)
+
+ return bepinexVersion
+})
+
+ipcMain.handle('uninstall-bepinex', async () => {
+ const folderPath = `${silksongPath}\\BepInEx`
+ if (await fileExists(folderPath)) {
+ await fs.rm(folderPath, { recursive: true })
+ }
+
+ const bepinexFiles = [
+ ".doorstop_version",
+ "changelog.txt",
+ "doorstop_config.ini",
+ "winhttp.dll"
+ ]
+
+ for (const file of bepinexFiles) {
+ const filePath = `${silksongPath}\\${file}`
+ if (await fileExists(filePath)) {
+ await fs.unlink(filePath)
+ }
+ }
+ bepinexVersion = undefined
+ return bepinexVersion
})
\ No newline at end of file
diff --git a/preload.js b/preload.js
index 073673d..519dd17 100644
--- a/preload.js
+++ b/preload.js
@@ -24,5 +24,6 @@ contextBridge.exposeInMainWorld('electronAPI', {
});
contextBridge.exposeInMainWorld('bepinex', {
- install: () => ipcRenderer.invoke('install-bepinex')
+ install: () => ipcRenderer.invoke('install-bepinex'),
+ uninstall: () => ipcRenderer.invoke('uninstall-bepinex')
})
\ No newline at end of file
diff --git a/renderer/index.html b/renderer/index.html
index 4ac43e0..9a0c298 100644
--- a/renderer/index.html
+++ b/renderer/index.html
@@ -104,7 +104,7 @@
BepInEx V1.0.0 is installed
+