From e1cfecfefc8213feeda8d28cc825e9a0644de1e4 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sat, 28 Jul 2018 02:14:23 -0600 Subject: [PATCH] move killAll to own function --- usr/share/install-launcher.js | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/usr/share/install-launcher.js b/usr/share/install-launcher.js index b2fcfa2..b6f1332 100644 --- a/usr/share/install-launcher.js +++ b/usr/share/install-launcher.js @@ -7,6 +7,24 @@ var exec = require('child_process').exec; var path = require('path'); var Launcher = module.exports; +Launcher._killAll = function (fn) { + var psList = require('ps-list'); + psList().then(function (procs) { + procs.forEach(function (proc) { + if ('node' === proc.name && /\btelebitd\b/i.test(proc.cmd)) { + console.log(proc); + process.kill(proc.pid); + return true; + } + }); + // Two things: + // 1) wait to see if the process dies + // 2) wait to give time for the socket to connect + setTimeout(function () { + if (fn) { fn(null); return; } + }, 1.75 * 1000); + }); +}; Launcher._getError = function getError(err, stderr) { if (err) { return err; } if (stderr) { @@ -315,22 +333,7 @@ Launcher.uninstall = function (things, fn) { vars.userspace = (!things.telebitUser || (things.telebitUser === os.userInfo().username)) ? true : false; var launchers = { 'node': function () { - var psList = require('ps-list'); - psList().then(function (procs) { - procs.forEach(function (proc) { - if ('node' === proc.name && /telebitd/i.test(proc.cmd)) { - console.log(proc); - process.kill(proc.pid); - return true; - } - }); - // Two things: - // 1) wait to see if the process dies - // 2) wait to give time for the socket to connect - setTimeout(function () { - if (fn) { fn(null); return; } - }, 1.75 * 1000); - }); + Launcher._killAll(fn); } , 'launchctl': function () { var launcher = path.join(os.homedir(), 'Library/LaunchAgents/cloud.telebit.remote.plist');