From 7ef891c54e0e9b06efc09e0d5e328d900a31e958 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Sun, 5 Mar 2023 22:43:09 +0100 Subject: small cleanups and changes in comments I've made some code return early instead of adding more nesting, on top of this I've added some more comments in some files, rephrased a few things, and so on... --- src/modules/findgame.js | 42 ++++----- src/modules/gamepath.js | 31 ++++--- src/modules/is_running.js | 4 +- src/modules/launch.js | 8 +- src/modules/mods.js | 216 ++++++++++++++++++++++++++++------------------ src/modules/settings.js | 36 +++++--- src/modules/update.js | 22 ++--- src/modules/version.js | 6 +- 8 files changed, 218 insertions(+), 147 deletions(-) diff --git a/src/modules/findgame.js b/src/modules/findgame.js index 615c5b4..1c330df 100644 --- a/src/modules/findgame.js +++ b/src/modules/findgame.js @@ -9,14 +9,12 @@ const exec = util.promisify(require("child_process").exec); module.exports = async () => { let gamepath = ""; - // Autodetect path - // Windows only using powershell and windows registery - // Get-Item -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Respawn\Titanfall2\ + // autodetect path through Powershell and Windows registry if (process.platform == "win32") { try { const {stdout} = await exec("Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\\SOFTWARE\\Respawn\\Titanfall2\\ -Name \"Install Dir\"", {"shell":"powershell.exe"}); - const gamepath = stdout.split('\n') + gamepath = stdout.split('\n') .filter(r => r.indexOf("Install Dir") !== -1)[0] .replace(/\s+/g,' ') .trim() @@ -26,12 +24,13 @@ module.exports = async () => { } catch (err) {} } - // Detect using Steam VDF + // reads, then parses VDF files, to search for Titanfall function readvdf(data) { - // Parse read_data - data = vdf.parse(data); + data = vdf.parse(data); // parse read_data + // list of folders where the game could possibly be installed at let values = Object.values(data["libraryfolders"]); + if (typeof values[values.length - 1] != "object") { values.pop(1); } @@ -49,16 +48,18 @@ module.exports = async () => { } } - let folders = []; + let vdf_files = []; + + // set `folders` to paths where the VDF file can be switch (process.platform) { case "win32": - folders = ["C:\\Program Files (x86)\\Steam\\steamapps\\libraryfolders.vdf"]; + vdf_files = ["C:\\Program Files (x86)\\Steam\\steamapps\\libraryfolders.vdf"]; break case "linux": case "openbsd": case "freebsd": let home = app.getPath("home"); - folders = [ + vdf_files = [ path.join(home, "/.steam/steam/steamapps/libraryfolders.vdf"), path.join(home, ".var/app/com.valvesoftware.Steam/.steam/steam/steamapps/libraryfolders.vdf"), path.join(home, ".var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/libraryfolders.vdf") @@ -66,20 +67,15 @@ module.exports = async () => { break } - if (folders.length > 0) { - for (let i = 0; i < folders.length; i++) { - if (! fs.existsSync(folders[i])) {continue} - console.log("Searching VDF file at:", folders[i]); + // searches VDF files + for (let i = 0; i < vdf_files.length; i++) { + if (! fs.existsSync(vdf_files[i])) {continue} + console.log("Searching VDF file at:", vdf_files[i]); - let data = fs.readFileSync(folders[i]); - let read_vdf = readvdf(data.toString()); - if (read_vdf) {return read_vdf} - } + let data = fs.readFileSync(vdf_files[i]); + let read_vdf = readvdf(data.toString()); + if (read_vdf) {return read_vdf} } - if (gamepath) { - return gamepath; - } else { - return false; - } + return gamepath || false; } diff --git a/src/modules/gamepath.js b/src/modules/gamepath.js index 93290ec..af98f79 100644 --- a/src/modules/gamepath.js +++ b/src/modules/gamepath.js @@ -9,32 +9,38 @@ const settings = require("./settings"); let gamepath = {}; -// Returns true/false depending on if the gamepath currently exists/is +// returns true/false depending on if the gamepath currently exists/is // mounted, used to avoid issues... gamepath.exists = () => { return fs.existsSync(settings.gamepath); } -// Requests to set the game path +// requests to set the game path // -// If running with CLI it takes in the --setpath argument otherwise it +// if running with CLI it takes in the --setpath argument otherwise it // open the systems file browser for the user to select a path. -gamepath.set = async (win, forcedialog) => { +gamepath.set = async (win, force_dialog) => { + // actually sets and saves the gamepath in the settings function set_gamepath(folder) { + // set settings settings.gamepath = folder; settings.zip = path.join(settings.gamepath + "/northstar.zip"); - settings.save(); + + settings.save(); // save settings + + // tell the renderer the path has changed win.webContents.send("newpath", settings.gamepath); ipcMain.emit("newpath", null, settings.gamepath); - - modpath = path.join(settings.gamepath, "R2Northstar/mods"); } if (! win) { // CLI + // sets the path to the --setpath argument's value set_gamepath(cli.param("setpath")); } else { // GUI - if (! forcedialog) { - function set_gamepath(folder, forcedialog) { + // unless specified, we will first try to automatically find the + // gamepath, and then later fallback to the GUI/manual selection + if (! force_dialog) { + function set_gamepath(folder, force_dialog) { settings.gamepath = folder; settings.zip = path.join(settings.gamepath + "/northstar.zip"); settings.save(); @@ -51,12 +57,13 @@ gamepath.set = async (win, forcedialog) => { win.alert(lang("general.missingpath")); } - // Fallback to manual selection + // fallback to GUI/manual selection dialog.showOpenDialog({properties: ["openDirectory"]}).then(res => { if (res.canceled) { ipcMain.emit("newpath", null, false); return; } + if (! fs.existsSync(path.join(res.filePaths[0], "Titanfall2.exe"))) { ipcMain.emit("wrong-path"); return; @@ -70,7 +77,9 @@ gamepath.set = async (win, forcedialog) => { } } -// periodically check for the gamepath still existing +// periodically check for the gamepath still existing, in case the +// folder is on a disk that gets unmounted, or anything similar, we dont +// want to assume the gamepath is available forever and ever. setInterval(() => { if (gamepath.exists()) { ipcMain.emit("gui-getmods"); diff --git a/src/modules/is_running.js b/src/modules/is_running.js index 5e0b67e..746df5c 100644 --- a/src/modules/is_running.js +++ b/src/modules/is_running.js @@ -15,7 +15,7 @@ async function check_processes(processes) { reject(false); } - // While we could use a Node module to do this instead, I + // while we could use a Node module to do this instead, I // decided not to do so. As this achieves exactly the same // thing. And it's not much more clunky. let cmd = (() => { @@ -28,12 +28,10 @@ async function check_processes(processes) { exec(cmd, (err, stdout) => { for (let i = 0; i < processes.length; i++) { if (stdout.includes(processes[i])) { - console.log("running") resolve(true); break } - console.log("not running") if (i == processes.length - 1) {resolve(false)} } }); diff --git a/src/modules/launch.js b/src/modules/launch.js index 765c348..82de109 100644 --- a/src/modules/launch.js +++ b/src/modules/launch.js @@ -6,11 +6,12 @@ const lang = require("../lang"); const win = require("./window"); const settings = require("./settings"); -// Launches the game +// launches the game // -// Either Northstar or Vanilla. Linux support is not currently a thing, +// either Northstar or Vanilla. Linux support is not currently a thing, // however it'll be added at some point. function launch(game_version) { + // return early, and show error message if on Linux if (process.platform == "linux") { win.alert(lang("cli.launch.linuxerror")); console.error("error:", lang("cli.launch.linuxerror")); @@ -18,7 +19,10 @@ function launch(game_version) { return; } + // change current directory to gamepath process.chdir(settings.gamepath); + + // launch the requested game version switch(game_version) { case "vanilla": console.log(lang("general.launching"), "Vanilla..."); diff --git a/src/modules/mods.js b/src/modules/mods.js index 6abed96..095e501 100644 --- a/src/modules/mods.js +++ b/src/modules/mods.js @@ -22,14 +22,15 @@ function update_path() { mods.path = path.join(settings.gamepath, "R2Northstar/mods"); }; update_path(); -// Returns a list of mods +// returns a list of mods // -// It'll return 3 arrays, all, enabled, disabled. all being a +// it'll return 3 arrays, all, enabled, disabled. all being a // combination of the other two, enabled being enabled mods, and you // guessed it, disabled being disabled mods. mods.list = () => { update_path(); + // make sure Northstar is actually installed if (version.northstar() == "unknown") { win.log(lang("general.notinstalled")); console.log("error: " + lang("general.notinstalled")); @@ -40,8 +41,11 @@ mods.list = () => { let enabled = []; let disabled = []; + // return early if the mods folder doesn't even exist if (! fs.existsSync(mods.path)) { + // create the folder for later fs.mkdirSync(path.join(mods.path), {recursive: true}); + return { enabled: [], disabled: [], @@ -51,44 +55,54 @@ mods.list = () => { let files = fs.readdirSync(mods.path); files.forEach((file) => { - if (fs.statSync(path.join(mods.path, file)).isDirectory()) { - let modjson = path.join(mods.path, file, "mod.json"); - if (fs.existsSync(modjson)) { - let mod = json(modjson); - if (! mod) {return} - - let obj = { - Author: false, - Version: "unknown", - Name: "unknown", - FolderName: file, - ...mod} - - obj.Disabled = ! mods.modfile.get(obj.Name); - - let manifest_file = path.join(mods.path, file, "manifest.json"); - if (fs.existsSync(manifest_file)) { - let manifest = json(manifest_file); - if (manifest != false) { - obj.ManifestName = manifest.name; - if (obj.Version == "unknown") { - obj.Version = manifest.version_number; - } - } - } + // return early if `file` isn't a folder + if (! fs.statSync(path.join(mods.path, file)).isDirectory()) { + return; + } - let author_file = path.join(mods.path, file, "thunderstore_author.txt"); - if (fs.existsSync(author_file)) { - obj.Author = fs.readFileSync(author_file, "utf8"); - } + let modjson = path.join(mods.path, file, "mod.json"); + + // return early if mod.json doesn't exist or isn't a file + if (! fs.existsSync(modjson) || ! fs.statSync(modjson).isFile()) { + return; + } - if (obj.Disabled) { - disabled.push(obj); - } else { - enabled.push(obj); + let mod = json(modjson); + if (! mod) {return} + + let obj = { + Author: false, + Version: "unknown", + Name: "unknown", + FolderName: file, + ...mod} + + obj.Disabled = ! mods.modfile.get(obj.Name); + + // add manifest data from manifest.json, if it exists + let manifest_file = path.join(mods.path, file, "manifest.json"); + if (fs.existsSync(manifest_file)) { + let manifest = json(manifest_file); + if (manifest != false) { + obj.ManifestName = manifest.name; + if (obj.Version == "unknown") { + obj.Version = manifest.version_number; } } } + + // add author data from author file, if it exists + let author_file = path.join(mods.path, file, "thunderstore_author.txt"); + if (fs.existsSync(author_file)) { + obj.Author = fs.readFileSync(author_file, "utf8"); + } + + // add mod to their respective disabled or enabled Array + if (obj.Disabled) { + disabled.push(obj); + } else { + enabled.push(obj); + } }) return { @@ -98,15 +112,16 @@ mods.list = () => { }; } -// Gets information about a mod +// gets information about a mod // -// Folder name, version, name and whatever else is in the mod.json, keep +// folder name, version, name and whatever else is in the mod.json, keep // in mind if the mod developer didn't format their JSON file the // absolute basics will be provided and we can't know the version or // similar. mods.get = (mod) => { update_path(); + // make sure Northstar is actually installed if (version.northstar() == "unknown") { win.log(lang("general.notinstalled")); console.log("error: " + lang("general.notinstalled")); @@ -114,63 +129,80 @@ mods.get = (mod) => { return false; } + // retrieve list of mods let list = mods.list().all; + // search for mod in list for (let i = 0; i < list.length; i++) { if (list[i].Name == mod) { + // found mod, return data return list[i]; } else {continue} } + // mod wasn't found return false; } +// makes sure enabledmods.json exists function modfile_pre() { mods.modfile.file = path.join(mods.path, "..", "enabledmods.json"); + // check that the folder enabledmods.json is in exists, and create + // it if it doesn't exist if (! fs.existsSync(mods.path)) { fs.mkdirSync(path.join(mods.path), {recursive: true}); } + // check that enabledmods.json itself exists, and create it if not if (! fs.existsSync(mods.modfile.file)) { fs.writeFileSync(mods.modfile.file, "{}"); } } -// Manages the enabledmods.json file +// manages the enabledmods.json file // -// It can both return info about the file, but also toggle mods in it, +// it can both return info about the file, but also toggle mods in it, // generate the file itself, and so on. mods.modfile = {}; +// generate the enabledmods.json file mods.modfile.gen = () => { modfile_pre(); let names = {}; - let list = mods.list().all; + let list = mods.list().all; // get list of all mods for (let i = 0; i < list.length; i++) { + // add every mod to the list names[list[i].Name] = true } + // write the actual file fs.writeFileSync(mods.modfile.file, JSON.stringify(names)); } -mods.modfile.disable = (mod) => { +// enable/disable a mod inside enabledmods.json +mods.modfile.set = (mod, state) => { modfile_pre(); - let data = json(mods.modfile.file); - data[mod] = false; + let data = json(mods.modfile.file); // get current data + data[mod] = state; // set mod state + + // write new data fs.writeFileSync(mods.modfile.file, JSON.stringify(data)); } -mods.modfile.enable = (mod) => { - modfile_pre(); +// disable a mod inside enabledmods.json +mods.modfile.disable = (mod) => { + return mods.modfile.set(mod, false); +} - let data = json(mods.modfile.file); - data[mod] = true; - fs.writeFileSync(mods.modfile.file, JSON.stringify(data)); +// enable a mod inside enabledmods.json +mods.modfile.enable = (mod) => { + return mods.modfile.set(mod, true); } +// toggle a mod inside enabledmods.json mods.modfile.toggle = (mod) => { modfile_pre(); @@ -184,23 +216,25 @@ mods.modfile.toggle = (mod) => { fs.writeFileSync(mods.modfile.file, JSON.stringify(data)); } +// return whether a mod is disabled or enabled mods.modfile.get = (mod) => { modfile_pre(); + // read enabledmods.json let data = json(mods.modfile.file); - if (data[mod]) { + if (data[mod]) { // enabled return true; - } else if (data[mod] === false) { + } else if (data[mod] === false) { // disabled return false; - } else { + } else { // fallback to enabled return true; } } -// Installs mods from a file path +// installs mods from a file path // -// Either a zip or folder is supported, we'll also try to search inside +// either a zip or folder is supported, we'll also try to search inside // the zip or folder to see if buried in another folder or not, as // sometimes that's the case. mods.install = (mod, opts) => { @@ -422,17 +456,19 @@ mods.install = (mod, opts) => { } } -// Installs mods from URL's +// installs mods from URL's // -// This'll simply download the file that the URL points to and then +// this'll simply download the file that the URL points to and then // install it with mods.install() mods.installFromURL = (url, author) => { update_path(); + // download mod to a temporary location https.get(url, (res) => { let tmp = path.join(app.getPath("cache"), "vipertmp"); let modlocation = path.join(tmp, "/mod.zip"); + // make sure the temporary folder exists if (fs.existsSync(tmp)) { if (! fs.statSync(tmp).isDirectory()) { fs.rmSync(tmp); @@ -444,11 +480,14 @@ mods.installFromURL = (url, author) => { } } + // write out the file to the temporary location let stream = fs.createWriteStream(modlocation); res.pipe(stream); stream.on("finish", () => { stream.close(); + + // attempt to install the downloaded mod mods.install(modlocation, { author: author }) @@ -456,13 +495,14 @@ mods.installFromURL = (url, author) => { }) } -// Removes mods +// removes mods // -// Takes in the names of the mod then removes it, no confirmation, +// takes in the names of the mod then removes it, no confirmation, // that'd be up to the GUI. mods.remove = (mod) => { update_path(); + // make sure Northstar is actually installed if (version.northstar() == "unknown") { win.log(lang("general.notinstalled")); console.log("error: " + lang("general.notinstalled")); @@ -470,6 +510,7 @@ mods.remove = (mod) => { return false; } + // removes all mods installed, no exceptions if (mod == "allmods") { let modlist = mods.list().all; for (let i = 0; i < modlist.length; i++) { @@ -478,11 +519,6 @@ mods.remove = (mod) => { return } - let disabled = path.join(mods.path, "disabled"); - if (! fs.existsSync(disabled)) { - fs.mkdirSync(disabled); - } - let mod_name = mods.get(mod).FolderName; if (! mod_name) { console.log("error: " + lang("cli.mods.cantfind")); @@ -492,38 +528,45 @@ mods.remove = (mod) => { let path_to_mod = path.join(mods.path, mod_name); - if (mods.get(mod).Disabled) { - path_to_mod = path.join(disabled, mod_name); + // return early if path_to_mod isn't a folder + if (! fs.statSync(path_to_mod).isDirectory()) { + return cli.exit(1); } - if (fs.statSync(path_to_mod).isDirectory()) { - let manifestname = null; - if (fs.existsSync(path.join(path_to_mod, "manifest.json"))) { - manifestname = require(path.join(path_to_mod, "manifest.json")).name; - } + let manifestname = null; - fs.rmSync(path_to_mod, {recursive: true}); - console.log(lang("cli.mods.removed")); - cli.exit(); - ipcMain.emit("gui-getmods"); - ipcMain.emit("removed-mod", "", { - name: mod.replace(/^.*(\\|\/|\:)/, ""), - manifestname: manifestname - }); - } else { - cli.exit(1); + // if the mod has a manifest.json we want to save it now so we can + // send it later when telling the renderer about the deleted mod + if (fs.existsSync(path.join(path_to_mod, "manifest.json"))) { + manifestname = require(path.join(path_to_mod, "manifest.json")).name; } + + // actually remove the mod itself + fs.rmSync(path_to_mod, {recursive: true}); + + console.log(lang("cli.mods.removed")); + cli.exit(); + + ipcMain.emit("gui-getmods"); // send updated list to renderer + + // tell the renderer that the mod has been removed, along with + // relevant info for it to properly update everything graphically + ipcMain.emit("removed-mod", "", { + name: mod.replace(/^.*(\\|\/|\:)/, ""), + manifestname: manifestname + }); } -// Toggles mods +// toggles mods // -// If a mod is enabled it'll disable it, vice versa it'll enable it if +// if a mod is enabled it'll disable it, vice versa it'll enable it if // it's disabled. You could have a direct .disable() function if you // checked for if a mod is already disable and if not run the function. // However we currently have no need for that. mods.toggle = (mod, fork) => { update_path(); + // make sure Northstar is actually installed if (version.northstar() == "unknown") { win.log(lang("general.notinstalled")); console.log("error: " + lang("general.notinstalled")); @@ -531,10 +574,11 @@ mods.toggle = (mod, fork) => { return false; } + // toggles all mods, thereby inverting the current enabled states if (mod == "allmods") { - let modlist = mods.list().all; - for (let i = 0; i < modlist.length; i++) { - mods.toggle(modlist[i].Name, true); + let modlist = mods.list().all; // get list of all mods + for (let i = 0; i < modlist.length; i++) { // run through list + mods.toggle(modlist[i].Name, true); // enable mod } console.log(lang("cli.mods.toggledall")); @@ -542,11 +586,15 @@ mods.toggle = (mod, fork) => { return } + // toggle specific mod mods.modfile.toggle(mod); + if (! fork) { console.log(lang("cli.mods.toggled")); cli.exit(); } + + // send updated modlist to renderer ipcMain.emit("gui-getmods"); } diff --git a/src/modules/settings.js b/src/modules/settings.js index d0a2db1..d71ea2a 100644 --- a/src/modules/settings.js +++ b/src/modules/settings.js @@ -7,7 +7,7 @@ const lang = require("../lang"); var invalid_settings = false; -// Base settings +// base settings var settings = { gamepath: "", lang: "en-US", @@ -19,7 +19,7 @@ var settings = { nsargs: "-multiple", zip: "/northstar.zip", - // These files won't be overwritten when installing/updating + // these files won't be overwritten when installing/updating // Northstar, useful for config files excludes: [ "ns_startup_args.txt", @@ -27,16 +27,19 @@ var settings = { ] } -// Creates the settings file with the base settings if it doesn't exist. +// creates the settings file with the base settings if it doesn't exist. if (fs.existsSync("viper.json")) { let conf = json("viper.json"); - // Validates viper.json + // validates viper.json if (! conf) { invalid_settings = true; } - settings = {...settings, ...conf}; + settings = { + ...settings, ...conf + } + settings.zip = path.join(settings.gamepath + "/northstar.zip"); let args = path.join(settings.gamepath, "ns_startup_args.txt"); @@ -47,24 +50,37 @@ if (fs.existsSync("viper.json")) { console.log(lang("general.missingpath")); } -// As to not have to do the same one liner a million times, this +// as to not have to do the same one liner a million times, this // function exists, as the name suggests, it simply writes the current // settings to the disk. // -// You can also pass a settings object to the function and it'll try and +// you can also pass a settings object to the function and it'll try and // merge it together with the already existing settings settings.save = (obj = {}) => { - if (invalid_settings) {return false} + // refuse to save if settings aren't valid + if (invalid_settings) { + return false; + } - let settings_content = {...settings, ...obj}; + let settings_content = { + ...settings, ...obj + } delete settings_content.save; + // write Northstar's startup argument file if (fs.existsSync(settings.gamepath)) { fs.writeFileSync(path.join(settings.gamepath, "ns_startup_args.txt"), settings.nsargs); } - fs.writeFileSync(app.getPath("appData") + "/viper.json", JSON.stringify({...settings, ...obj})); + let stringified_settings = JSON.stringify({ + ...settings, ...obj + }) + + let settings_file = app.getPath("appData") + "/viper.json"; + + // write the settings file + fs.writeFileSync(settings_file, stringified_settings); } module.exports = settings; diff --git a/src/modules/update.js b/src/modules/update.js index 2c75cac..82a6df1 100644 --- a/src/modules/update.js +++ b/src/modules/update.js @@ -43,9 +43,9 @@ function exclude_files() { // whether update.northstar_auto_update() has already been run before let is_auto_updating = false; -// Handles auto updating Northstar. +// handles auto updating Northstar. // -// It uses isGameRunning() to ensure it doesn't run while the game is +// it uses isGameRunning() to ensure it doesn't run while the game is // running, as that may have all kinds of issues. update.northstar_autoupdate = () => { if (! settings.nsupdate || ! fs.existsSync("viper.json") || settings.gamepath.length === 0) { @@ -59,7 +59,7 @@ update.northstar_autoupdate = () => { console.log(lang("cli.autoupdates.checking")); - // Checks if NS is outdated + // checks if NS is outdated if (await northstar_update_available()) { console.log(lang("cli.autoupdates.available")); if (await is_running.game()) { @@ -104,9 +104,9 @@ async function northstar_update_available() { } } -// Updates Viper itself +// updates Viper itself // -// This uses electron updater to easily update and publish releases, it +// this uses electron updater to easily update and publish releases, it // simply fetches it from GitHub and updates if it's outdated, very // useful. Not much we have to do on our side. update.viper = (autoinstall) => { @@ -139,13 +139,13 @@ update.viper = (autoinstall) => { autoUpdater.checkForUpdatesAndNotify(); } -// Installs/Updates Northstar +// installs/Updates Northstar // -// If Northstar is already installed it'll be an update, otherwise it'll +// if Northstar is already installed it'll be an update, otherwise it'll // install it. It simply downloads the Northstar archive from GitHub, if // it's outdated, then extracts it into the game path. // -// As to handle not overwriting files we rename certain files to +// as to handle not overwriting files we rename certain files to // .excluded, then rename them back after the extraction. The // unzip module does not support excluding files directly. update.northstar = async () => { @@ -186,13 +186,13 @@ update.northstar = async () => { exclude_files(); - // Start the download of the zip + // start the download of the zip https.get(requests.getLatestNsVersionLink(), (res) => { let stream = fs.createWriteStream(settings.zip); res.pipe(stream); let received = 0; - // Progress messages, we should probably switch this to + // progress messages, we should probably switch this to // percentage instead of how much is downloaded. res.on("data", (chunk) => { received += chunk.length; @@ -206,7 +206,7 @@ update.northstar = async () => { win.log(lang("gui.update.extracting")); ipcMain.emit("ns-update-event", "gui.update.extracting"); console.log(lang("cli.update.downloaddone")); - // Extracts the zip, this is the part where we're actually + // extracts the zip, this is the part where we're actually // installing Northstar. extract.pipe(unzip.Extract({path: settings.gamepath})) diff --git a/src/modules/version.js b/src/modules/version.js index 73e7bed..652ffc5 100644 --- a/src/modules/version.js +++ b/src/modules/version.js @@ -6,8 +6,8 @@ const settings = require("./settings"); let version = {}; -// Returns the current Northstar version -// If not installed it'll return "unknown" +// returns the current Northstar version +// if not installed it'll return "unknown" version.northstar = () => { // if NorthstarLauncher.exe doesn't exist, always return "unknown" if (! fs.existsSync(path.join(settings.gamepath, "NorthstarLauncher.exe"))) { @@ -62,7 +62,7 @@ version.northstar = () => { return baseVersion; } -// Returns the Titanfall 2 version from gameversion.txt file. +// returns the Titanfall 2 version from gameversion.txt file. // If it fails it simply returns "unknown" // // TODO: This file is present on Origin install, should check if it's -- cgit v1.2.3