aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlystrasz <contact@remyraes.com>2022-01-10 20:41:19 +0100
committerAlystrasz <contact@remyraes.com>2022-01-10 20:41:19 +0100
commitb32ad187349b55f36b95ebf8a476c77a65c2af36 (patch)
tree26b0187f6e2d594bd485d2d3970db0de5e83ceaa
parent2dd43ab44db1a9eb29bc1e53f69810f0e2bb6012 (diff)
downloadViper-b32ad187349b55f36b95ebf8a476c77a65c2af36.tar.gz
Viper-b32ad187349b55f36b95ebf8a476c77a65c2af36.zip
[feat] adding code to check if a tf2 process is running
-rw-r--r--src/utils.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/utils.js b/src/utils.js
index b944a03..a0ce010 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -12,6 +12,7 @@ const requests = require("./requests");
const unzip = require("unzipper");
const run = require("child_process").spawn;
+const exec = require("child_process").exec;
const { https } = require("follow-redirects");
process.chdir(app.getPath("appData"));
@@ -35,11 +36,36 @@ if (fs.existsSync("viper.json")) {
}
+async function _isGameRunning() {
+ return new Promise(resolve => {
+ let procs = ["Titanfall2.exe", "Titanfall2-unpacked.exe", "NorthstarLauncher2.exe"];
+ let cmd = (() => {
+ switch (process.platform) {
+ case "linux": return "ps -A";
+ case "win32": return "tasklist";
+ }
+ })();
+
+ exec(cmd, (err, stdout) => {
+ for (let i = 0; i < procs.length; i++) {
+ if (stdout.includes(procs[i])) {
+ resolve(true);
+ break
+ }
+
+ if (i == procs.length - 1) {resolve(false)}
+ }
+ });
+ });
+}
+
northstar_auto_updates: {
if (!settings.autoupdate || !fs.existsSync("viper.json") || settings.gamepath.length === 0)
break northstar_auto_updates;
async function _checkForUpdates() {
+ console.log(await _isGameRunning());
+
const localVersion = getNSVersion();
const distantVersion = await requests.getLatestNsVersion();
console.log('Checking for Northstar updates...');