@@ -8,6 +8,7 @@ import WebSocket from "ws"
88import pkg from "electron"
99const { app, dialog } = pkg
1010import { getPort } from "get-port-please"
11+ import { sync as commandExistsSync } from "command-exists"
1112import isElectron from "is-electron"
1213import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_schemas.json" with { type : "json" }
1314import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json" with { type : "json" }
@@ -58,7 +59,8 @@ function get_available_port() {
5859}
5960
6061async function run_script (
61- command ,
62+ executable_name ,
63+ executable_path ,
6264 args ,
6365 expected_response ,
6466 timeout_seconds = 30 ,
@@ -68,6 +70,9 @@ async function run_script(
6870 reject ( "Timed out after " + timeout_seconds + " seconds" )
6971 } , timeout_seconds * 1000 )
7072
73+ const command = commandExistsSync ( executable_name )
74+ ? executable_name
75+ : path . join ( executable_path , executable_name )
7176 const child = child_process . spawn ( command , args , {
7277 encoding : "utf8" ,
7378 shell : true ,
@@ -109,7 +114,8 @@ async function run_script(
109114}
110115
111116async function run_back (
112- command ,
117+ executable_name ,
118+ executable_path ,
113119 args = {
114120 project_folder_path,
115121 upload_folder_path : undefined ,
@@ -128,22 +134,36 @@ async function run_back(
128134 "--allowed_origin http://localhost:*" ,
129135 "--timeout " + 0 ,
130136 ]
131- console . log ( "run_back" , command , back_args )
132- await run_script ( command , back_args , "Serving Flask app" )
137+ console . log ( "run_back" , executable_name , executable_path , back_args )
138+ await run_script (
139+ executable_name ,
140+ executable_path ,
141+ back_args ,
142+ "Serving Flask app" ,
143+ )
133144 resolve ( port )
134145 } )
135146}
136147
137- async function run_viewer ( command , args = { project_folder_path } ) {
148+ async function run_viewer (
149+ executable_name ,
150+ executable_path ,
151+ args = { project_folder_path } ,
152+ ) {
138153 return new Promise ( async ( resolve , reject ) => {
139154 const port = await get_available_port ( )
140155 const viewer_args = [
141156 "--port " + port ,
142157 "--data_folder_path " + args . project_folder_path ,
143158 "--timeout " + 0 ,
144159 ]
145- console . log ( "run_viewer" , command , viewer_args )
146- await run_script ( command , viewer_args , "Starting factory" )
160+ console . log ( "run_viewer" , executable_name , executable_path , viewer_args )
161+ await run_script (
162+ executable_name ,
163+ executable_path ,
164+ viewer_args ,
165+ "Starting factory" ,
166+ )
147167 resolve ( port )
148168 } )
149169}
@@ -224,19 +244,27 @@ function kill_viewer(viewer_port) {
224244async function run_browser (
225245 script_name ,
226246 microservices_options = {
227- back : { command , args : { project_folder_path } } ,
228- viewer : { command , args : { project_folder_path } } ,
247+ back : { executable_name , executable_path , args : { project_folder_path } } ,
248+ viewer : { executable_name , executable_path , args : { project_folder_path } } ,
229249 } ,
230250) {
231251 console . log ( "microservices_options" , microservices_options )
232- const back_promise = run_back ( microservices_options . back . command , {
233- ...microservices_options . back . args ,
234- } )
252+ const back_promise = run_back (
253+ microservices_options . back . executable_name ,
254+ microservices_options . back . executable_path ,
255+ {
256+ ...microservices_options . back . args ,
257+ } ,
258+ )
235259 console . log ( "back_promise" , back_promise )
236260
237- const viewer_promise = run_viewer ( microservices_options . viewer . command , {
238- ...microservices_options . viewer . args ,
239- } )
261+ const viewer_promise = run_viewer (
262+ microservices_options . viewer . executable_name ,
263+ microservices_options . viewer . executable_path ,
264+ {
265+ ...microservices_options . viewer . args ,
266+ } ,
267+ )
240268 console . log ( "viewer_promise" , viewer_promise )
241269
242270 const [ back_port , viewer_port ] = await Promise . all ( [
0 commit comments