@@ -509,12 +509,18 @@ export async function portFromDockerCompose(): Promise<{ port: number; docker: b
509
509
const workspaceFolderPath = workspaceFolder . fsPath ;
510
510
const workspaceRootPath = vscode . workspace . workspaceFolders [ 0 ] . uri . fsPath ;
511
511
512
- const cwd : string = await fileExists ( vscode . Uri . file ( path . join ( workspaceFolderPath , file ) ) ) . then ( ( exists ) => {
512
+ const cwd : string = await fileExists ( vscode . Uri . file ( path . join ( workspaceFolderPath , file ) ) ) . then ( async ( exists ) => {
513
513
if ( exists ) {
514
- return workspaceRootPath ;
515
- } else {
516
- throw new Error ( `File '${ file } ' not found.` ) ;
514
+ return workspaceFolderPath ;
515
+ }
516
+ if ( workspaceFolderPath !== workspaceRootPath ) {
517
+ exists = await fileExists ( vscode . Uri . file ( path . join ( workspaceRootPath , file ) ) ) ;
518
+ if ( exists ) {
519
+ return workspaceRootPath ;
520
+ }
521
+ throw new Error ( `File '${ file } ' not found in ${ workspaceFolderPath } or ${ workspaceRootPath } .` ) ;
517
522
}
523
+ throw new Error ( `File '${ file } ' not found in ${ workspaceFolderPath } .` ) ;
518
524
} ) ;
519
525
520
526
if ( ! cwd ) {
@@ -530,7 +536,7 @@ export async function portFromDockerCompose(): Promise<{ port: number; docker: b
530
536
reject ( error . message ) ;
531
537
}
532
538
if ( ! stdout . replaceAll ( "\r" , "" ) . split ( "\n" ) . includes ( service ) ) {
533
- reject ( `Service '${ service } ' not found in '${ file } ', or not running.` ) ;
539
+ reject ( `Service '${ service } ' not found in '${ path . join ( cwd , file ) } ', or not running.` ) ;
534
540
}
535
541
536
542
exec ( `${ cmd } port --protocol=tcp ${ service } ${ internalPort } ` , { cwd } , ( error , stdout ) => {
@@ -539,7 +545,7 @@ export async function portFromDockerCompose(): Promise<{ port: number; docker: b
539
545
}
540
546
const [ , port ] = stdout . match ( / : ( \d + ) / ) || [ ] ;
541
547
if ( ! port ) {
542
- reject ( `Port ${ internalPort } not published for service '${ service } '.` ) ;
548
+ reject ( `Port ${ internalPort } not published for service '${ service } ' in ' ${ path . join ( cwd , file ) } ' .` ) ;
543
549
}
544
550
resolve ( { port : parseInt ( port , 10 ) , docker : true , service } ) ;
545
551
} ) ;
0 commit comments