diff --git a/src/index.ts b/src/index.ts index c949b73..7fdece3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -31,6 +31,10 @@ export type DockerComposeConfigServicesResult = { services: string[] } +export type DockerComposeConfigVolumesResult = { + volumes: string[] +} + export interface IDockerComposeLogOptions extends IDockerComposeOptions { follow?: boolean } @@ -335,10 +339,20 @@ export const configServices = async function ( } } -export const configVolumes = function ( +export const configVolumes = async function ( options?: IDockerComposeOptions -): Promise { - return execCompose('config', ['--volumes'], options) +): Promise> { + try { + const result = await execCompose('config', ['--volumes'], options) + const nonEmpty = (v: string) => v !== '' + const volumes = result.out.split('\n').filter(nonEmpty) + return { + ...result, + data: { volumes } + } + } catch (error) { + return Promise.reject(error) + } } export const ps = function ( diff --git a/test/docker-compose-42.yml b/test/docker-compose-42.yml index 4d635a2..37b3b65 100644 --- a/test/docker-compose-42.yml +++ b/test/docker-compose-42.yml @@ -5,7 +5,7 @@ services: image: nginx:1.19.9-alpine command: 'nginx -g "daemon off;"' volumes: - - ./volume:/mountedvolume + # - ./volume:/mountedvolume - db-data:/mountedsecondvolume volumes: diff --git a/test/index.test.ts b/test/index.test.ts index 19d145c..48fcf25 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -540,8 +540,9 @@ test('config show data for docker-compose files (volumes)', async (): Promise => {