Remove old installs when detected
This commit is contained in:
parent
d2594463c0
commit
06bdfe301b
|
@ -1,4 +1,6 @@
|
|||
import {app} from "electron";
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
|
||||
import ipc from "./modules/ipc";
|
||||
import BrowserWindow from "./modules/browserwindow";
|
||||
|
@ -20,17 +22,29 @@ if (!process.argv.includes("--vanilla")) {
|
|||
}
|
||||
|
||||
// Enable DevTools on Stable.
|
||||
let fakeAppSettings;
|
||||
Object.defineProperty(global, "appSettings", {
|
||||
get() {
|
||||
return fakeAppSettings;
|
||||
},
|
||||
set(value) {
|
||||
if (!value.hasOwnProperty("settings")) value.settings = {};
|
||||
value.settings.DANGEROUS_ENABLE_DEVTOOLS_ONLY_ENABLE_IF_YOU_KNOW_WHAT_YOURE_DOING = true;
|
||||
fakeAppSettings = value;
|
||||
},
|
||||
});
|
||||
try {
|
||||
let fakeAppSettings;
|
||||
Object.defineProperty(global, "appSettings", {
|
||||
get() {
|
||||
return fakeAppSettings;
|
||||
},
|
||||
set(value) {
|
||||
if (!value.hasOwnProperty("settings")) value.settings = {};
|
||||
value.settings.DANGEROUS_ENABLE_DEVTOOLS_ONLY_ENABLE_IF_YOU_KNOW_WHAT_YOURE_DOING = true;
|
||||
fakeAppSettings = value;
|
||||
},
|
||||
});
|
||||
}
|
||||
catch (_) {
|
||||
// Detect old install and delete it
|
||||
const appPath = app.getAppPath(); // Should point to app or app.asar
|
||||
const oldInstall = path.resolve(appPath, "..", "app");
|
||||
if (fs.existsSync(oldInstall)) {
|
||||
fs.rmdirSync(oldInstall, {recursive: true});
|
||||
app.quit();
|
||||
app.relaunch();
|
||||
}
|
||||
}
|
||||
|
||||
// Needs to run this after Discord but before ready()
|
||||
if (!process.argv.includes("--vanilla")) {
|
||||
|
|
|
@ -128,17 +128,23 @@ const registerPreload = (event, path) => {
|
|||
|
||||
export default class IPCMain {
|
||||
static registerEvents() {
|
||||
ipc.on(IPCEvents.GET_PATH, getPath);
|
||||
ipc.on(IPCEvents.RELAUNCH, relaunch);
|
||||
ipc.on(IPCEvents.OPEN_DEVTOOLS, openDevTools);
|
||||
ipc.on(IPCEvents.CLOSE_DEVTOOLS, closeDevTools);
|
||||
ipc.on(IPCEvents.TOGGLE_DEVTOOLS, toggleDevTools);
|
||||
ipc.on(IPCEvents.INSPECT_ELEMENT, inspectElement);
|
||||
ipc.on(IPCEvents.MINIMUM_SIZE, setMinimumSize);
|
||||
ipc.on(IPCEvents.DEVTOOLS_WARNING, stopDevtoolsWarning);
|
||||
ipc.on(IPCEvents.REGISTER_PRELOAD, registerPreload);
|
||||
ipc.handle(IPCEvents.RUN_SCRIPT, runScript);
|
||||
ipc.handle(IPCEvents.OPEN_DIALOG, openDialog);
|
||||
ipc.handle(IPCEvents.OPEN_WINDOW, createBrowserWindow);
|
||||
try {
|
||||
ipc.on(IPCEvents.GET_PATH, getPath);
|
||||
ipc.on(IPCEvents.RELAUNCH, relaunch);
|
||||
ipc.on(IPCEvents.OPEN_DEVTOOLS, openDevTools);
|
||||
ipc.on(IPCEvents.CLOSE_DEVTOOLS, closeDevTools);
|
||||
ipc.on(IPCEvents.TOGGLE_DEVTOOLS, toggleDevTools);
|
||||
ipc.on(IPCEvents.INSPECT_ELEMENT, inspectElement);
|
||||
ipc.on(IPCEvents.MINIMUM_SIZE, setMinimumSize);
|
||||
ipc.on(IPCEvents.DEVTOOLS_WARNING, stopDevtoolsWarning);
|
||||
ipc.on(IPCEvents.REGISTER_PRELOAD, registerPreload);
|
||||
ipc.handle(IPCEvents.RUN_SCRIPT, runScript);
|
||||
ipc.handle(IPCEvents.OPEN_DIALOG, openDialog);
|
||||
ipc.handle(IPCEvents.OPEN_WINDOW, createBrowserWindow);
|
||||
}
|
||||
catch (err) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue