aboutsummaryrefslogtreecommitdiff
path: root/commands
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-02-12 19:49:42 +0100
committerMinteck <contact@minteck.org>2022-02-12 19:49:42 +0100
commit5c62e5a5c5f61b43b7788528872996772e39e10e (patch)
tree0b72c77b2605154e069432fadce187a5d738d3a0 /commands
parentd3796f6d61f0e3a6481a0974c7d6f4c83af2f860 (diff)
downloadtwilight-5c62e5a5c5f61b43b7788528872996772e39e10e.tar.gz
twilight-5c62e5a5c5f61b43b7788528872996772e39e10e.tar.bz2
twilight-5c62e5a5c5f61b43b7788528872996772e39e10e.zip
Update
Diffstat (limited to 'commands')
-rw-r--r--commands/install.js11
-rw-r--r--commands/remove.js15
2 files changed, 19 insertions, 7 deletions
diff --git a/commands/install.js b/commands/install.js
index 6f0df0c..b08ebe5 100644
--- a/commands/install.js
+++ b/commands/install.js
@@ -145,12 +145,17 @@ module.exports = async (argv) => {
spinner.succeed("Extracting package... done");
console.log(" Size change: +" + require('../hooks/size')(pkg.id));
+ let exec = argv.package;
+ 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 (os.platform() === "win32" && typeof pkg.executable.windows === "string") {
- fs.writeFileSync(os.homedir() + "/.twilight/binaries/" + pkg.id + ".bat", pkg.executable.windows);
+ fs.writeFileSync(os.homedir() + "/.twilight/binaries/" + exec + ".bat", pkg.executable.windows);
} else if (os.platform() === "linux" && typeof pkg.executable.linux === "string") {
- fs.writeFileSync(os.homedir() + "/.twilight/binaries/" + pkg.id + ".sh", pkg.executable.linux);
+ fs.writeFileSync(os.homedir() + "/.twilight/binaries/" + exec + ".sh", pkg.executable.linux);
} else if (os.platform() === "darwin" && typeof pkg.executable.mac === "string") {
- fs.writeFileSync(os.homedir() + "/.twilight/binaries/" + pkg.id + ".sh", pkg.executable.mac);
+ fs.writeFileSync(os.homedir() + "/.twilight/binaries/" + exec + ".sh", pkg.executable.mac);
}
let postinstall = [];
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");