diff options
author | Minteck <contact@minteck.org> | 2022-02-12 12:09:34 +0100 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-02-12 12:09:34 +0100 |
commit | 38e7fbe2f99a5d0b6a69e54ab3af7ebf451e8f4f (patch) | |
tree | 33266f2ba82dd1e22fe85cf77bc0b559e3917af8 /commands/remove.js | |
parent | 01160246e4a0c0052181c72a53737e356ea7d02d (diff) | |
download | twilight-38e7fbe2f99a5d0b6a69e54ab3af7ebf451e8f4f.tar.gz twilight-38e7fbe2f99a5d0b6a69e54ab3af7ebf451e8f4f.tar.bz2 twilight-38e7fbe2f99a5d0b6a69e54ab3af7ebf451e8f4f.zip |
Update
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 |