@@ -473,12 +473,18 @@ export async function portFromDockerCompose(): Promise<{ port: number; docker: b
473473 const workspaceFolderPath = workspaceFolder . fsPath ;
474474 const workspaceRootPath = vscode . workspace . workspaceFolders [ 0 ] . uri . fsPath ;
475475
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 ) => {
477477 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 } .` ) ;
481486 }
487+ throw new Error ( `File '${ file } ' not found in ${ workspaceFolderPath } .` ) ;
482488 } ) ;
483489
484490 if ( ! cwd ) {
@@ -494,7 +500,7 @@ export async function portFromDockerCompose(): Promise<{ port: number; docker: b
494500 reject ( error . message ) ;
495501 }
496502 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.` ) ;
498504 }
499505
500506 exec ( `${ cmd } port --protocol=tcp ${ service } ${ internalPort } ` , { cwd } , ( error , stdout ) => {
@@ -503,7 +509,7 @@ export async function portFromDockerCompose(): Promise<{ port: number; docker: b
503509 }
504510 const [ , port ] = stdout . match ( / : ( \d + ) / ) || [ ] ;
505511 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 ) } ' .` ) ;
507513 }
508514 resolve ( { port : parseInt ( port , 10 ) , docker : true , service } ) ;
509515 } ) ;
0 commit comments