@@ -261,17 +261,17 @@ function run(port) {
261
261
262
262
function getProcessNameOnPort ( port ) {
263
263
var execOptions = { encoding : 'utf8' } ;
264
- var processesCommand = 'lsof -i:' + port + ' -P -t'
265
264
266
265
try {
267
- var processIds = execSync ( processesCommand , execOptions ) . match ( / ( \S + ) / g) ;
266
+ var processIds = execSync ( 'lsof -i:' + port + ' -P -t' , execOptions ) . match ( / ( \S + ) / g) ;
268
267
269
- var namedProcesses = processIds . map ( function ( processId ) {
270
- var command = 'ps -o command -p ' + processId + ' | sed -n 2p | tr -d "\n"' ;
271
- return execSync ( command , execOptions ) ;
268
+ var processCommandsAndDirectories = processIds . map ( function ( processId ) {
269
+ var processCommand = execSync ( 'ps -o command -p ' + processId + ' | sed -n 2p' , execOptions ) ;
270
+ var processDirectory = execSync ( 'lsof -p ' + processId + ' | grep cwd | awk \'{print " in " $9}\'' , execOptions ) ;
271
+ return chalk . blue ( processCommand ) + chalk . cyan ( processDirectory ) ;
272
272
} ) ;
273
273
274
- return namedProcesses . join ( ', \n ' ) ;
274
+ return processCommandsAndDirectories . join ( '\n ' ) ;
275
275
} catch ( e ) {
276
276
return null ;
277
277
}
@@ -289,7 +289,7 @@ detect(DEFAULT_PORT).then(port => {
289
289
var existingProcess = getProcessNameOnPort ( DEFAULT_PORT ) ;
290
290
var question =
291
291
chalk . yellow ( 'Something is already running on port ' + DEFAULT_PORT + '.' +
292
- ( ( existingProcess ) ? ' Probably:\n ' + chalk . cyan ( existingProcess ) : '' ) ) +
292
+ ( ( existingProcess ) ? ' Probably:\n ' + existingProcess : '' ) ) +
293
293
'\n\nWould you like to run the app on another port instead?' ;
294
294
295
295
prompt ( question , true ) . then ( shouldChangePort => {
0 commit comments