@@ -140,33 +140,42 @@ function run(port) {
140140
141141// We attempt to use the default port but if it is busy, we offer the user to
142142// run on a different port. `detect()` Promise resolves to the next free port.
143- detect ( DEFAULT_PORT , HOST ) . then ( port => {
144- if ( port === DEFAULT_PORT ) {
145- run ( port ) ;
146- return ;
147- }
143+ detect ( DEFAULT_PORT , HOST ) . then (
144+ port => {
145+ if ( port === DEFAULT_PORT ) {
146+ run ( port ) ;
147+ return ;
148+ }
148149
149- if ( isInteractive ) {
150- clearConsole ( ) ;
151- const existingProcess = getProcessForPort ( DEFAULT_PORT ) ;
152- const question = {
153- type : 'confirm' ,
154- name : 'shouldChangePort' ,
155- message : chalk . yellow (
156- `Something is already running on port ${ DEFAULT_PORT } .` +
157- `${ existingProcess ? ` Probably:\n ${ existingProcess } ` : '' } `
158- ) + '\n\nWould you like to run the app on another port instead?' ,
159- default : true ,
160- } ;
161-
162- inquirer . prompt ( question ) . then ( answer => {
163- if ( answer . shouldChangePort ) {
164- run ( port ) ;
165- }
166- } ) ;
167- } else {
150+ if ( isInteractive ) {
151+ clearConsole ( ) ;
152+ const existingProcess = getProcessForPort ( DEFAULT_PORT ) ;
153+ const question = {
154+ type : 'confirm' ,
155+ name : 'shouldChangePort' ,
156+ message : chalk . yellow (
157+ `Something is already running on port ${ DEFAULT_PORT } .` +
158+ `${ existingProcess ? ` Probably:\n ${ existingProcess } ` : '' } `
159+ ) + '\n\nWould you like to run the app on another port instead?' ,
160+ default : true ,
161+ } ;
162+
163+ inquirer . prompt ( question ) . then ( answer => {
164+ if ( answer . shouldChangePort ) {
165+ run ( port ) ;
166+ }
167+ } ) ;
168+ } else {
169+ console . log (
170+ chalk . red ( `Something is already running on port ${ DEFAULT_PORT } .` )
171+ ) ;
172+ }
173+ } ,
174+ err => {
168175 console . log (
169- chalk . red ( `Something is already running on port ${ DEFAULT_PORT } .` )
176+ chalk . red ( `Could not find an open port at ${ chalk . bold ( HOST ) } .` )
170177 ) ;
178+ console . log ( 'Network error message: ' + err . message || err ) ;
179+ console . log ( ) ;
171180 }
172- } ) ;
181+ ) ;
0 commit comments