diff options
-rw-r--r-- | src/utils.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/utils.js b/src/utils.js index 68cd6c1..faa0f13 100644 --- a/src/utils.js +++ b/src/utils.js @@ -34,6 +34,33 @@ if (fs.existsSync("viper.json")) { console.log(lang("general.missingpath")); } + +northstar_auto_updates: { + if (!settings.autoupdate || !fs.existsSync("viper.json") || settings.gamepath.length === 0) + break northstar_auto_updates; + + async function _checkForUpdates() { + const localVersion = getNSVersion(); + const distantVersion = await requests.getLatestNsVersion(); + console.log('Checking for Northstar updates...'); + + if (localVersion !== distantVersion) { + console.log('Northstar update available! Launching update process.'); + update(); + } else { + console.log('No Northstar update available.') + } + + setTimeout( + _checkForUpdates, + 15 * 60 * 1000 // update checking interval must be bigger than cache validity duration + ); + } + + _checkForUpdates(); +} + + function setpath(win) { if (! win) { settings.gamepath = cli.param("setpath"); |