mirror of
https://github.com/danbulant/docker-compose
synced 2026-05-27 05:51:45 +00:00
refactor: replace variables by chaining
This commit is contained in:
parent
3be99e8360
commit
9443c7ebdc
1 changed files with 18 additions and 13 deletions
17
src/index.ts
17
src/index.ts
|
|
@ -103,12 +103,17 @@ export const mapPorts = (
|
||||||
}
|
}
|
||||||
|
|
||||||
export const mapPsOutput = (output: string): DockerComposePsResult => {
|
export const mapPsOutput = (output: string): DockerComposePsResult => {
|
||||||
const allLines = output.split(`\n`).filter(nonEmptyString)
|
const services = output
|
||||||
const linesWithServices = allLines.filter((_, index) => index > 1)
|
.split(`\n`)
|
||||||
const services = linesWithServices.map((line) => {
|
.filter(nonEmptyString)
|
||||||
const [nameString, commandString, stateString, allPortsString] = line.split(
|
.filter((_, index) => index > 1)
|
||||||
/\s{3,}/
|
.map((line) => {
|
||||||
)
|
const [
|
||||||
|
nameString,
|
||||||
|
commandString,
|
||||||
|
stateString,
|
||||||
|
allPortsString
|
||||||
|
] = line.split(/\s{3,}/)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: nameString.trim(),
|
name: nameString.trim(),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue