From 5c62e5a5c5f61b43b7788528872996772e39e10e Mon Sep 17 00:00:00 2001 From: Minteck Date: Sat, 12 Feb 2022 19:49:42 +0100 Subject: Update --- commands/remove.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'commands/remove.js') diff --git a/commands/remove.js b/commands/remove.js index 081d87d..899aaa6 100644 --- a/commands/remove.js +++ b/commands/remove.js @@ -22,6 +22,10 @@ module.exports = async (argv, reinstalling) => { name = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + argv.package + ".json").toString()).name; } + if (argv.package === "twilight") { + die(c.red("error: ") + "package 'twilight' is system package and cannot be uninstalled, use 'twilight-setup' instead"); + } + instInfo = installed.filter(i => i.id === argv.package)[0]; console.log(" Uninstalling '" + name + "'...") @@ -58,11 +62,14 @@ module.exports = async (argv, reinstalling) => { delete installed[installed.map(i => i.id).indexOf(argv.package)]; fs.writeFileSync(os.homedir() + "/.twilight/installed.json", JSON.stringify(installed)); - if (os.platform() === "win32") { - if (fs.existsSync(os.homedir() + "/.twilight/binaries/" + argv.package + ".bat")) fs.unlinkSync(os.homedir() + "/.twilight/binaries/" + argv.package + ".bat"); - } else { - if (fs.existsSync(os.homedir() + "/.twilight/binaries/" + argv.package + ".sh")) fs.unlinkSync(os.homedir() + "/.twilight/binaries/" + argv.package + ".sh"); + let exec = argv.package; + if (!packages.includes(argv.package)) { + exec = argv.package; + } else if (typeof JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + argv.package + ".json").toString()).execname === "string") { + exec = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + argv.package + ".json").toString()).execname; } + if (fs.existsSync(os.homedir() + "/.twilight/binaries/" + exec + ".bat")) fs.unlinkSync(os.homedir() + "/.twilight/binaries/" + exec + ".bat"); + if (fs.existsSync(os.homedir() + "/.twilight/binaries/" + exec + ".sh")) fs.unlinkSync(os.homedir() + "/.twilight/binaries/" + exec + ".sh"); spinner.succeed("Removing package... done"); -- cgit