@@ -171,11 +171,21 @@ function printServerUrls(
171
171
base : string ,
172
172
info : Logger [ 'info' ]
173
173
) : void {
174
+ const urls : Array < { label : string ; url : string } > = [ ]
175
+
174
176
if ( hostname . host === '127.0.0.1' ) {
175
- const url = `${ protocol } ://${ hostname . name } :${ colors . bold ( port ) } ${ base } `
176
- info ( ` > Local: ${ colors . cyan ( url ) } ` )
177
+ urls . push ( {
178
+ label : 'Local' ,
179
+ url : colors . cyan (
180
+ `${ protocol } ://${ hostname . name } :${ colors . bold ( port ) } ${ base } `
181
+ )
182
+ } )
183
+
177
184
if ( hostname . name !== '127.0.0.1' ) {
178
- info ( ` > Network: ${ colors . dim ( 'use `--host` to expose' ) } ` )
185
+ urls . push ( {
186
+ label : 'Network' ,
187
+ url : colors . dim ( `use ${ colors . white ( colors . bold ( '--host' ) ) } to expose` )
188
+ } )
179
189
}
180
190
} else {
181
191
Object . values ( os . networkInterfaces ( ) )
@@ -189,14 +199,24 @@ function printServerUrls(
189
199
// Node >= v18
190
200
( typeof detail . family === 'number' && detail . family === 4 ) )
191
201
)
192
- . map ( ( detail ) => {
193
- const type = detail . address . includes ( '127.0.0.1' )
194
- ? 'Local: '
195
- : 'Network: '
202
+ . forEach ( ( detail ) => {
196
203
const host = detail . address . replace ( '127.0.0.1' , hostname . name )
197
204
const url = `${ protocol } ://${ host } :${ colors . bold ( port ) } ${ base } `
198
- return ` > ${ type } ${ colors . cyan ( url ) } `
205
+ const label = detail . address . includes ( '127.0.0.1' ) ? 'Local' : 'Network'
206
+
207
+ urls . push ( { label, url : colors . cyan ( url ) } )
199
208
} )
200
- . forEach ( ( msg ) => info ( msg ) )
201
209
}
210
+
211
+ const length = urls . reduce (
212
+ ( length , { label } ) => Math . max ( length , label . length ) ,
213
+ 0
214
+ )
215
+ urls . forEach ( ( { label, url : text } ) => {
216
+ info (
217
+ ` ${ colors . green ( '➜' ) } ${ colors . bold ( label ) } : ${ ' ' . repeat (
218
+ length - label . length
219
+ ) } ${ text } `
220
+ )
221
+ } )
202
222
}
0 commit comments