diff options
Diffstat (limited to 'src/modules/update.js')
-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 |