diff options
Diffstat (limited to 'commands/remove.js')
-rw-r--r-- | commands/remove.js | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/commands/remove.js b/commands/remove.js index 5643dd3..56fc847 100644 --- a/commands/remove.js +++ b/commands/remove.js @@ -16,7 +16,7 @@ module.exports = async (argv, reinstalling) => { let dir = argv.package.substring(0, 1).replace(/[^a-zA-Z0-9]/gm, "#"); if (!packages.includes(argv.package)) { - console.log(c.yellow("warn: ") + "package '" + argv.package + "' not in repository anymore"); + console.log(c.yellow("warn: ") + "package '" + argv.package + "' not in repository anymore, unable to fetch for name"); name = argv.package; } else { name = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + argv.package + ".json").toString()).name; @@ -58,4 +58,23 @@ 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)); spinner.succeed("Removing package... done"); + + if (!packages.includes(argv.package)) { + console.log(c.yellow("warn: ") + "package '" + argv.package + "' not in repository anymore, unable to fetch for post-remove hooks"); + } else { + ppr = JSON.parse(fs.readFileSync(home + "/repository/" + dir + "/" + argv.package + ".json").toString()).postremove; + + let postremove = []; + if (os.platform() === "win32") postremove = ppr.windows; + if (os.platform() === "linux") postremove = ppr.linux; + if (os.platform() === "darwin") postremove = ppr.mac; + + if (postremove.length > 0) { + spinner = ora("Running post-remove hooks...").start(); + for (let hook of postremove) { + require('child_process').execSync(hook, { stdio: "inherit" }) + } + spinner.succeed("Running post-remove hooks... done"); + } + } }
\ No newline at end of file |