aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2024-02-05 00:00:41 +0100
committer0neGal <mail@0negal.com>2024-02-05 00:00:41 +0100
commit0e93aeb17215e1d9e5587ce6ee01aa5887f1d207 (patch)
treeb975a8e16c162d9bef3c486f971daeacd6192a97 /src
parent0b3cdfb3d31c18d94bd54634239deabc28e0597e (diff)
downloadViper-0e93aeb17215e1d9e5587ce6ee01aa5887f1d207.tar.gz
Viper-0e93aeb17215e1d9e5587ce6ee01aa5887f1d207.zip
fixed trying to remove core mods that dont exist
Some code relating to removing core mods when updating/installing didn't account for `R2Northstar/mods` not even existing, thought I made checks for that already, managed to mess them up, oopsie whoopsie.
Diffstat (limited to 'src')
-rw-r--r--src/modules/update.js20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/modules/update.js b/src/modules/update.js
index 7140fcd..658e989 100644
--- a/src/modules/update.js
+++ b/src/modules/update.js
@@ -219,12 +219,17 @@ function remove_core_mods() {
// make sure the "R2Northstar/mods" folder exists, on top of making
// sure that, it is in fact a folder
let mod_dir = path.join(settings().gamepath, "R2Northstar/mods");
- if (! fs.existsSync(mod_dir) && ! fs.statSync(mod_dir).isFile()) {
- return
+ if (! fs.existsSync(mod_dir) || fs.statSync(mod_dir).isFile()) {
+ return;
}
- // get list of items in `mod_dir`
- let mods = fs.readdirSync(mod_dir);
+ let mods = [];
+ let deleted_core_mods = false;
+
+ try {
+ // try to get list of items in `mod_dir`
+ mods = fs.readdirSync(mod_dir);
+ }catch(err) {}
// run through list
for (let i = 0; i < mods.length; i++) {
@@ -234,10 +239,15 @@ function remove_core_mods() {
fs.rmSync(path.join(mod_dir, mods[i]), {
recursive: true
})
+
+ deleted_core_mods = true;
}
}
- console.ok("Removed existing core mods!");
+ // display message, if we even deleted any mods
+ if (deleted_core_mods) {
+ console.ok("Removed existing core mods!");
+ }
}
// installs/Updates Northstar