From 987eb760234e4dda5cec945756305978d638cdbb Mon Sep 17 00:00:00 2001 From: Brenden Harrell Date: Sun, 23 May 2021 15:21:10 -0500 Subject: [PATCH] Add: Finish Unified Uninstall Script --- Launch-Scripts/create-shortcut.js | 7 +++--- Launch-Scripts/uninstall.js => uninstall.js | 24 ++++++++++++++++++--- 2 files changed, 24 insertions(+), 7 deletions(-) rename Launch-Scripts/uninstall.js => uninstall.js (56%) diff --git a/Launch-Scripts/create-shortcut.js b/Launch-Scripts/create-shortcut.js index e3c62d1a4..97f443bae 100644 --- a/Launch-Scripts/create-shortcut.js +++ b/Launch-Scripts/create-shortcut.js @@ -1,6 +1,5 @@ const path = require("path"); const fs = require("fs"); -const process = require("process"); const { exec } = require("child_process"); const os = require("os"); @@ -12,11 +11,11 @@ let name = dirs[dirs.length - 2]; // Windows Shortcuts if (os.platform() == "win32") { // Paths and Icon for Windows shortcuts - let target = path.join( process.cwd(), "launch-windows.bat"); - let icon = path.join( process.cwd(), "superalgos.ico"); + let target = path.join( __dirname, "launch-windows.bat"); + let icon = path.join( __dirname, "superalgos.ico"); let shortcutPaths = [ path.join( os.homedir(), "Desktop", `${name}.lnk`), - path.join( os.homedir(), "AppData", "Roaming", "Microsoft", "Windows", "Start Menu", "Programs", "Superalgos.lnk") + path.join( os.homedir(), "AppData", "Roaming", "Microsoft", "Windows", "Start Menu", "Programs", `${name}.lnk`) ] // Place Shortcuts using powershell diff --git a/Launch-Scripts/uninstall.js b/uninstall.js similarity index 56% rename from Launch-Scripts/uninstall.js rename to uninstall.js index 305fd55d3..0203d7e5d 100644 --- a/Launch-Scripts/uninstall.js +++ b/uninstall.js @@ -5,12 +5,30 @@ const { exec } = require("child_process"); // Get the name of the main directory let cwd = __dirname; let dirs = cwd.split(path.sep); -let name = dirs[dirs.length - 2]; +let name = dirs[dirs.length - 1]; -// Windows Shortcuts +// Remove Windows Shortcuts if (os.platform() == "win32") { + let desktop = path.join( os.homedir(), "Desktop", `${name}.lnk`) + let startMenu = path.join( os.homedir(), "AppData", "Roaming", "Microsoft", "Windows", "Start Menu", "Programs", `${name}.lnk`) -// Linux Shortcuts + // Remove .desktop files + let command = `del "${desktop}" & del "${startMenu}"` + exec( command, + function ( error ){ + if (error) { + console.log(''); + console.log("There was an error uninstalling shortcuts: "); + console.log(''); + console.log( error ); + return; + } else { + console.log(''); + console.log("Shortcuts have been uninstalled successfully."); + } + }); + +// Remove Linux Shortcuts } else if (os.platform() == "linux") { // Check for Ubuntu let version = os.version();