File tree 1 file changed +10
-18
lines changed
1 file changed +10
-18
lines changed Original file line number Diff line number Diff line change @@ -1015,26 +1015,18 @@ export async function main(options: IServerOptions): Promise<void> {
1015
1015
process . exit ( 1 ) ;
1016
1016
} ) ;
1017
1017
1018
- if ( parsedArgs . socket ) {
1019
- server . listen ( parsedArgs . socket , ( ) => {
1020
- logService . info ( `Server listening on ${ parsedArgs . socket } ` ) ;
1021
- } ) ;
1022
- } else {
1023
- let port = 3000 ;
1024
- if ( parsedArgs . port ) {
1025
- port = Number ( parsedArgs . port ) ;
1026
- } else if ( typeof options . port === 'number' ) {
1027
- port = options . port ;
1028
- }
1029
-
1030
- const host = parsedArgs . host || '0.0.0.0' ;
1031
- server . listen ( port , host , ( ) => {
1032
- const addressInfo = server . address ( ) as net . AddressInfo ;
1018
+ const port = parsedArgs . port ? Number ( parsedArgs . port ) : ( typeof options . port === 'number' ? options . port : 3000 ) ;
1019
+ const host = parsedArgs . host || '0.0.0.0' ;
1020
+ const listenOpts : net . ListenOptions = parsedArgs . socket ? { path : parsedArgs . socket } : { port, host } ;
1021
+ server . listen ( listenOpts , ( ) => {
1022
+ const addressInfo = server . address ( ) ;
1023
+ if ( typeof addressInfo === 'string' ) {
1024
+ logService . info ( `Server listening on ${ addressInfo } ` ) ;
1025
+ } else if ( addressInfo ) {
1033
1026
const address = addressInfo . address === '0.0.0.0' || addressInfo . address === '127.0.0.1' ? 'localhost' : addressInfo . address ;
1034
1027
const formattedPort = addressInfo . port === 80 ? '' : String ( addressInfo . port ) ;
1035
1028
logService . info ( `Web UI available at http://${ address } :${ formattedPort } ` ) ;
1036
- } ) ;
1037
- }
1038
-
1029
+ }
1030
+ } ) ;
1039
1031
} ) ;
1040
1032
}
You can’t perform that action at this time.
0 commit comments