aboutsummaryrefslogtreecommitdiff
path: root/src/modules/kill.js
blob: 7482bed74f2198ce8f350fa3c192b34cca40a1c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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;