diff options
author | 0neGal <mail@0negal.com> | 2024-02-05 00:00:41 +0100 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2024-02-05 00:00:41 +0100 |
commit | 0e93aeb17215e1d9e5587ce6ee01aa5887f1d207 (patch) | |
tree | b975a8e16c162d9bef3c486f971daeacd6192a97 | |
parent | 0b3cdfb3d31c18d94bd54634239deabc28e0597e (diff) | |
download | Viper-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.
-rw-r--r-- | src/modules/update.js | 20 |
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 |