Remove old installs when detected
This commit is contained in:
parent
d2594463c0
commit
06bdfe301b
|
@ -1,4 +1,6 @@
|
||||||
import {app} from "electron";
|
import {app} from "electron";
|
||||||
|
import path from "path";
|
||||||
|
import fs from "fs";
|
||||||
|
|
||||||
import ipc from "./modules/ipc";
|
import ipc from "./modules/ipc";
|
||||||
import BrowserWindow from "./modules/browserwindow";
|
import BrowserWindow from "./modules/browserwindow";
|
||||||
|
@ -20,17 +22,29 @@ if (!process.argv.includes("--vanilla")) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable DevTools on Stable.
|
// Enable DevTools on Stable.
|
||||||
let fakeAppSettings;
|
try {
|
||||||
Object.defineProperty(global, "appSettings", {
|
let fakeAppSettings;
|
||||||
get() {
|
Object.defineProperty(global, "appSettings", {
|
||||||
return fakeAppSettings;
|
get() {
|
||||||
},
|
return fakeAppSettings;
|
||||||
set(value) {
|
},
|
||||||
if (!value.hasOwnProperty("settings")) value.settings = {};
|
set(value) {
|
||||||
value.settings.DANGEROUS_ENABLE_DEVTOOLS_ONLY_ENABLE_IF_YOU_KNOW_WHAT_YOURE_DOING = true;
|
if (!value.hasOwnProperty("settings")) value.settings = {};
|
||||||
fakeAppSettings = value;
|
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()
|
// Needs to run this after Discord but before ready()
|
||||||
if (!process.argv.includes("--vanilla")) {
|
if (!process.argv.includes("--vanilla")) {
|
||||||
|
|
|
@ -128,17 +128,23 @@ const registerPreload = (event, path) => {
|
||||||
|
|
||||||
export default class IPCMain {
|
export default class IPCMain {
|
||||||
static registerEvents() {
|
static registerEvents() {
|
||||||
ipc.on(IPCEvents.GET_PATH, getPath);
|
try {
|
||||||
ipc.on(IPCEvents.RELAUNCH, relaunch);
|
ipc.on(IPCEvents.GET_PATH, getPath);
|
||||||
ipc.on(IPCEvents.OPEN_DEVTOOLS, openDevTools);
|
ipc.on(IPCEvents.RELAUNCH, relaunch);
|
||||||
ipc.on(IPCEvents.CLOSE_DEVTOOLS, closeDevTools);
|
ipc.on(IPCEvents.OPEN_DEVTOOLS, openDevTools);
|
||||||
ipc.on(IPCEvents.TOGGLE_DEVTOOLS, toggleDevTools);
|
ipc.on(IPCEvents.CLOSE_DEVTOOLS, closeDevTools);
|
||||||
ipc.on(IPCEvents.INSPECT_ELEMENT, inspectElement);
|
ipc.on(IPCEvents.TOGGLE_DEVTOOLS, toggleDevTools);
|
||||||
ipc.on(IPCEvents.MINIMUM_SIZE, setMinimumSize);
|
ipc.on(IPCEvents.INSPECT_ELEMENT, inspectElement);
|
||||||
ipc.on(IPCEvents.DEVTOOLS_WARNING, stopDevtoolsWarning);
|
ipc.on(IPCEvents.MINIMUM_SIZE, setMinimumSize);
|
||||||
ipc.on(IPCEvents.REGISTER_PRELOAD, registerPreload);
|
ipc.on(IPCEvents.DEVTOOLS_WARNING, stopDevtoolsWarning);
|
||||||
ipc.handle(IPCEvents.RUN_SCRIPT, runScript);
|
ipc.on(IPCEvents.REGISTER_PRELOAD, registerPreload);
|
||||||
ipc.handle(IPCEvents.OPEN_DIALOG, openDialog);
|
ipc.handle(IPCEvents.RUN_SCRIPT, runScript);
|
||||||
ipc.handle(IPCEvents.OPEN_WINDOW, createBrowserWindow);
|
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