@@ -473,12 +473,18 @@ export async function portFromDockerCompose(): Promise<{ port: number; docker: b
473
473
const workspaceFolderPath = workspaceFolder . fsPath ;
474
474
const workspaceRootPath = vscode . workspace . workspaceFolders [ 0 ] . uri . fsPath ;
475
475
476
- const cwd : string = await fileExists ( vscode . Uri . file ( path . join ( workspaceFolderPath , file ) ) ) . then ( ( exists ) => {
476
+ const cwd : string = await fileExists ( vscode . Uri . file ( path . join ( workspaceFolderPath , file ) ) ) . then ( async ( exists ) => {
477
477
if ( exists ) {
478
- return workspaceRootPath ;
479
- } else {
480
- throw new Error ( `File '${ file } ' not found.` ) ;
478
+ return workspaceFolderPath ;
479
+ }
480
+ if ( workspaceFolderPath !== workspaceRootPath ) {
481
+ exists = await fileExists ( vscode . Uri . file ( path . join ( workspaceRootPath , file ) ) ) ;
482
+ if ( exists ) {
483
+ return workspaceRootPath ;
484
+ }
485
+ throw new Error ( `File '${ file } ' not found in ${ workspaceFolderPath } or ${ workspaceRootPath } .` ) ;
481
486
}
487
+ throw new Error ( `File '${ file } ' not found in ${ workspaceFolderPath } .` ) ;
482
488
} ) ;
483
489
484
490
if ( ! cwd ) {
@@ -494,7 +500,7 @@ export async function portFromDockerCompose(): Promise<{ port: number; docker: b
494
500
reject ( error . message ) ;
495
501
}
496
502
if ( ! stdout . replaceAll ( "\r" , "" ) . split ( "\n" ) . includes ( service ) ) {
497
- reject ( `Service '${ service } ' not found in '${ file } ', or not running.` ) ;
503
+ reject ( `Service '${ service } ' not found in '${ path . join ( cwd , file ) } ', or not running.` ) ;
498
504
}
499
505
500
506
exec ( `${ cmd } port --protocol=tcp ${ service } ${ internalPort } ` , { cwd } , ( error , stdout ) => {
@@ -503,7 +509,7 @@ export async function portFromDockerCompose(): Promise<{ port: number; docker: b
503
509
}
504
510
const [ , port ] = stdout . match ( / : ( \d + ) / ) || [ ] ;
505
511
if ( ! port ) {
506
- reject ( `Port ${ internalPort } not published for service '${ service } '.` ) ;
512
+ reject ( `Port ${ internalPort } not published for service '${ service } ' in ' ${ path . join ( cwd , file ) } ' .` ) ;
507
513
}
508
514
resolve ( { port : parseInt ( port , 10 ) , docker : true , service } ) ;
509
515
} ) ;
0 commit comments