mirror of
https://github.com/danbulant/docker-compose
synced 2026-06-09 17:53:16 +00:00
fix: filter empty entries from config --services command
This commit is contained in:
parent
51b20b43d6
commit
ed91eba770
2 changed files with 5 additions and 4 deletions
|
|
@ -60,6 +60,8 @@ export type TypedDockerComposeResult<T> = {
|
||||||
data: T
|
data: T
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const nonEmptyString = (v: string) => v !== ''
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts supplied yml files to cli arguments
|
* 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
|
* 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<TypedDockerComposeResult<DockerComposeConfigServicesResult>> {
|
): Promise<TypedDockerComposeResult<DockerComposeConfigServicesResult>> {
|
||||||
try {
|
try {
|
||||||
const result = await execCompose('config', ['--services'], options)
|
const result = await execCompose('config', ['--services'], options)
|
||||||
const services = result.out.split('\n')
|
const services = result.out.split('\n').filter(nonEmptyString)
|
||||||
return {
|
return {
|
||||||
...result,
|
...result,
|
||||||
data: { services }
|
data: { services }
|
||||||
|
|
@ -344,8 +346,7 @@ export const configVolumes = async function (
|
||||||
): Promise<TypedDockerComposeResult<DockerComposeConfigVolumesResult>> {
|
): Promise<TypedDockerComposeResult<DockerComposeConfigVolumesResult>> {
|
||||||
try {
|
try {
|
||||||
const result = await execCompose('config', ['--volumes'], options)
|
const result = await execCompose('config', ['--volumes'], options)
|
||||||
const nonEmpty = (v: string) => v !== ''
|
const volumes = result.out.split('\n').filter(nonEmptyString)
|
||||||
const volumes = result.out.split('\n').filter(nonEmpty)
|
|
||||||
return {
|
return {
|
||||||
...result,
|
...result,
|
||||||
data: { volumes }
|
data: { volumes }
|
||||||
|
|
|
||||||
|
|
@ -528,7 +528,7 @@ test('config show data for docker-compose files (services)', async (): Promise<v
|
||||||
config: 'docker-compose-build.yml'
|
config: 'docker-compose-build.yml'
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(std.data.services.length).toBe(6)
|
expect(std.data.services.length).toBe(5)
|
||||||
expect(std.data.services[0]).toBe('build_test_1')
|
expect(std.data.services[0]).toBe('build_test_1')
|
||||||
expect(std.err).toBeFalsy()
|
expect(std.err).toBeFalsy()
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue