aboutsummaryrefslogtreecommitdiff
path: root/src/modules/kill.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/kill.js')
-rw-r--r--src/modules/kill.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/modules/kill.js b/src/modules/kill.js
new file mode 100644
index 0000000..7482bed
--- /dev/null
+++ b/src/modules/kill.js
@@ -0,0 +1,27 @@
+const exec = require("child_process").exec;
+
+// a simple function to kill processes with a certain name
+async function kill(process_name) {
+ return new Promise(resolve => {
+ let proc = process_name;
+ let cmd = (() => {
+ switch (process.platform) {
+ case "linux": return "killall " + proc;
+ case "win32": return "taskkill /IM " + proc + " /F";
+ }
+ })();
+
+ exec(cmd, (err, stdout) => {
+ // just try and fail silently if we don't find it w/e
+ resolve(true);
+ });
+ });
+}
+
+kill.process = kill;
+
+kill.origin = () => {
+ return kill("Origin.exe");
+}
+
+module.exports = kill;