From ed91eba770d3a32d82dda4e927d31ed4b6d01db4 Mon Sep 17 00:00:00 2001 From: Alexander Zeitler Date: Sun, 11 Apr 2021 15:59:53 +0200 Subject: [PATCH] fix: filter empty entries from `config --services` command --- src/index.ts | 7 ++++--- test/index.test.ts | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 7fdece3..bb859ef 100644 --- a/src/index.ts +++ b/src/index.ts @@ -60,6 +60,8 @@ export type TypedDockerComposeResult = { data: T } +const nonEmptyString = (v: string) => v !== '' + /** * Converts supplied yml files to cli arguments * https://docs.docker.com/compose/reference/overview/#use--f-to-specify-name-and-path-of-one-or-more-compose-files @@ -329,7 +331,7 @@ export const configServices = async function ( ): Promise> { try { const result = await execCompose('config', ['--services'], options) - const services = result.out.split('\n') + const services = result.out.split('\n').filter(nonEmptyString) return { ...result, data: { services } @@ -344,8 +346,7 @@ export const configVolumes = async function ( ): Promise> { try { const result = await execCompose('config', ['--volumes'], options) - const nonEmpty = (v: string) => v !== '' - const volumes = result.out.split('\n').filter(nonEmpty) + const volumes = result.out.split('\n').filter(nonEmptyString) return { ...result, data: { volumes } diff --git a/test/index.test.ts b/test/index.test.ts index 48fcf25..8c45276 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -528,7 +528,7 @@ test('config show data for docker-compose files (services)', async (): Promise