diff options
author | 0neGal <mail@0negal.com> | 2024-01-11 23:57:32 +0100 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2024-01-11 23:57:32 +0100 |
commit | 05ea0cc58c0e6d6ebd1fc7cd4a135cefe2ec7dfc (patch) | |
tree | 1b862bfdd78496f2f1bd5429c0c17851d3e99df8 /src/modules | |
parent | 897d4bd94d1111520404ea675940c4087d42a4ef (diff) | |
download | Viper-05ea0cc58c0e6d6ebd1fc7cd4a135cefe2ec7dfc.tar.gz Viper-05ea0cc58c0e6d6ebd1fc7cd4a135cefe2ec7dfc.zip |
updating Northstar now deletes existing core mods
This solves #223
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/update.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/modules/update.js b/src/modules/update.js index 881e02d..a45223a 100644 --- a/src/modules/update.js +++ b/src/modules/update.js @@ -141,6 +141,34 @@ update.viper = (autoinstall) => { autoUpdater.checkForUpdatesAndNotify(); } +// removes all mods in "R2Northstar/mods" starting with "Northstar." +function remove_core_mods() { + if (! gamepath.exists()) {return} + + // 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 + } + + // get list of items in `mod_dir` + let mods = fs.readdirSync(mod_dir); + + // run through list + for (let i = 0; i < mods.length; i++) { + // does the item starts with "Northstar."? + if (mods[i].match("Northstar\..*")) { + // remove the item + fs.rmSync(path.join(mod_dir, mods[i]), { + recursive: true + }) + } + } + + console.ok("Removed existing core mods!"); +} + // installs/Updates Northstar // // if Northstar is already installed it'll be an update, otherwise it'll @@ -262,6 +290,8 @@ update.northstar = async (force_install) => { }) stream.on("finish", () => { + remove_core_mods(); + stream.close(); let extract = fs.createReadStream(settings.zip); |