@@ -37,7 +37,7 @@ import * as path from 'path'
3737 * OR
3838 * - calls the getBinFolderPath going back a directory
3939 */
40- const checkForBinPath = ( baseDir : string ) => {
40+ const checkForBinPath = ( baseDir : string ) : string => {
4141 const serverbasePath = 'node_modules/@omega-edit/server'
4242
4343 // These two are checked as when testing locally it will want to use out/bin
@@ -46,26 +46,28 @@ const checkForBinPath = (baseDir: string) => {
4646 path . join ( baseDir , serverbasePath , 'out' , 'bin' ) ,
4747 ]
4848
49- for ( let i = 0 ; i < pathsToCheck . length ; i ++ ) {
50- if ( fs . existsSync ( pathsToCheck [ i ] ) ) return path . resolve ( pathsToCheck [ i ] )
49+ for ( const p of pathsToCheck ) {
50+ if ( fs . existsSync ( p ) ) return path . resolve ( p )
5151 }
5252
5353 return getBinFolderPath ( path . join ( baseDir , '..' ) )
5454}
5555
5656/**
57- *
57+ * Recursively finds the bin folder path
5858 * @param baseDir the base path to the directory to check against
5959 * @returns
6060 * - path to bin directory
6161 * OR
6262 * - recursively calls itself till path is found
6363 */
64- const getBinFolderPath = ( baseDir : string ) => {
64+ const getBinFolderPath = ( baseDir : string ) : string => {
6565 if ( ! baseDir . endsWith ( 'node_modules' ) ) {
66- if ( fs . readdirSync ( baseDir ) . includes ( 'node_modules' ) )
66+ if ( fs . readdirSync ( baseDir ) . includes ( 'node_modules' ) ) {
6767 return checkForBinPath ( baseDir )
68- else return getBinFolderPath ( path . join ( baseDir , '..' ) )
68+ } else {
69+ return getBinFolderPath ( path . join ( baseDir , '..' ) )
70+ }
6971 } else {
7072 return checkForBinPath ( baseDir . replace ( 'node_modules' , '' ) )
7173 }
@@ -74,7 +76,7 @@ const getBinFolderPath = (baseDir: string) => {
7476/**
7577 * Execute the server
7678 * @param args arguments to pass to the server
77- * @returns {ChildProcess } server process
79+ * @returns {Promise< ChildProcess> } server process
7880 */
7981async function executeServer ( args : string [ ] ) : Promise < ChildProcess > {
8082 const serverScript = path . join (
@@ -88,9 +90,10 @@ async function executeServer(args: string[]): Promise<ChildProcess> {
8890
8991 const serverProcess : ChildProcess = spawn ( serverScript , args , {
9092 cwd : path . dirname ( serverScript ) ,
91- stdio : 'ignore' ,
9293 detached : true ,
9394 shell : os . platform ( ) . startsWith ( 'win' ) , // use shell on Windows because it can't execute scripts directly
95+ stdio : [ 'ignore' , 'ignore' , 'ignore' ] ,
96+ windowsHide : true , // avoid showing a console window
9497 } )
9598
9699 serverProcess . on ( 'error' , ( err : Error ) => {
@@ -107,7 +110,7 @@ async function executeServer(args: string[]): Promise<ChildProcess> {
107110 * @param host hostname or IP address (default: 127.0.0.1)
108111 * @param pidfile resolved path to the PID file
109112 * @param logConf resolved path to a logback configuration file
110- * @returns {ChildProcess } server process
113+ * @returns {Promise< ChildProcess> } server process
111114 */
112115export async function runServer (
113116 port : number ,
0 commit comments