@@ -9,7 +9,7 @@ import os from "os"
99import pkg from "electron"
1010const { app, dialog } = pkg
1111import { getPort } from "get-port-please"
12- import pidtree from "pidtree "
12+ import kill from "tree-kill "
1313import isElectron from "is-electron"
1414import { fileURLToPath } from "url"
1515
@@ -72,28 +72,24 @@ async function kill_processes() {
7272 await processes . forEach ( async function ( proc ) {
7373 console . log ( `Process ${ proc } will be killed!` )
7474 try {
75- process . kill ( proc )
75+ kill ( proc )
7676 } catch ( error ) {
7777 console . log ( `${ error } Process ${ proc } could not be killed!` )
7878 }
7979 } )
8080}
8181
82- function register_children_processes ( proc ) {
83- pidtree ( proc . pid , { root : true } , function ( err , pids ) {
84- if ( err ) {
85- console . log ( "err" , err )
86- return
87- }
88- processes . push ( ...pids )
89- } )
82+ function register_process ( proc ) {
83+ if ( ! processes . includes ( proc . pid ) ) {
84+ processes . push ( proc . pid )
85+ }
9086}
9187
9288async function run_script (
9389 command ,
9490 args ,
9591 expected_response ,
96- timeout_seconds = 30 ,
92+ timeout_seconds = 30
9793) {
9894 return new Promise ( ( resolve , reject ) => {
9995 setTimeout ( ( ) => {
@@ -103,7 +99,7 @@ async function run_script(
10399 encoding : "utf8" ,
104100 shell : true ,
105101 } )
106- register_children_processes ( child )
102+ register_process ( child )
107103
108104 // You can also use a variable to save the output for when the script closes later
109105 child . stderr . setEncoding ( "utf8" )
@@ -119,7 +115,6 @@ async function run_script(
119115 //Here is the output
120116 data = data . toString ( )
121117 if ( data . includes ( expected_response ) ) {
122- register_children_processes ( child )
123118 resolve ( child )
124119 }
125120 console . log ( data )
@@ -145,7 +140,7 @@ async function run_back(port, project_folder_path) {
145140 return new Promise ( async ( resolve , reject ) => {
146141 const back_command = path . join (
147142 executable_path ( path . join ( "microservices" , "back" ) ) ,
148- executable_name ( "vease-back" ) ,
143+ executable_name ( "vease-back" )
149144 )
150145 const back_port = await get_available_port ( port )
151146 const back_args = [
@@ -164,7 +159,7 @@ async function run_viewer(port, data_folder_path) {
164159 return new Promise ( async ( resolve , reject ) => {
165160 const viewer_command = path . join (
166161 executable_path ( path . join ( "microservices" , "viewer" ) ) ,
167- executable_name ( "vease-viewer" ) ,
162+ executable_name ( "vease-viewer" )
168163 )
169164 const viewer_port = await get_available_port ( port )
170165 const viewer_args = [
@@ -224,7 +219,7 @@ async function run_browser(script_name) {
224219 const output = data . toString ( )
225220 console . log ( "NUXT OUTPUT" , output )
226221 const portMatch = output . match (
227- / A c c e p t i n g \ c o n n e c t i o n s \ a t \ h t t p : \/ \/ l o c a l h o s t : ( \d + ) / ,
222+ / A c c e p t i n g \ c o n n e c t i o n s \ a t \ h t t p : \/ \/ l o c a l h o s t : ( \d + ) /
228223 )
229224 if ( portMatch ) {
230225 resolve ( portMatch [ 1 ] )
@@ -240,7 +235,7 @@ export {
240235 executable_path ,
241236 get_available_port ,
242237 kill_processes ,
243- register_children_processes ,
238+ register_process ,
244239 run_script ,
245240 run_back ,
246241 run_viewer ,
0 commit comments