This commit is contained in:
Araxeus
2021-05-10 23:46:56 +03:00
parent 8cca9f3eeb
commit 78a7dcb7e8

View File

@ -263,12 +263,12 @@ app.on("ready", () => {
try { // check if shortcut is registered and valid try { // check if shortcut is registered and valid
const shortcutDetails = electron.shell.readShortcutLink(shortcutPath); // throw error if doesn't exist yet const shortcutDetails = electron.shell.readShortcutLink(shortcutPath); // throw error if doesn't exist yet
if (shortcutDetails.target !== appLocation || shortcutDetails.appUserModelId !== appID) { if (shortcutDetails.target !== appLocation || shortcutDetails.appUserModelId !== appID) {
throw undefined; throw "needUpdate";
} }
} catch { // if not valid -> Register shortcut } catch (error) { // if not valid -> Register shortcut
electron.shell.writeShortcutLink( electron.shell.writeShortcutLink(
shortcutPath, shortcutPath,
"create", error === "needUpdate" ? "update" : "create",
{ {
target: appLocation, target: appLocation,
cwd: appLocation.slice(0, appLocation.lastIndexOf(path.sep)), cwd: appLocation.slice(0, appLocation.lastIndexOf(path.sep)),