mirror of
https://github.com/danbulant/docker-compose
synced 2026-05-24 12:35:32 +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 => {
|
||||
const allLines = output.split(`\n`).filter(nonEmptyString)
|
||||
const linesWithServices = allLines.filter((_, index) => index > 1)
|
||||
const services = linesWithServices.map((line) => {
|
||||
const [nameString, commandString, stateString, allPortsString] = line.split(
|
||||
/\s{3,}/
|
||||
)
|
||||
const services = output
|
||||
.split(`\n`)
|
||||
.filter(nonEmptyString)
|
||||
.filter((_, index) => index > 1)
|
||||
.map((line) => {
|
||||
const [
|
||||
nameString,
|
||||
commandString,
|
||||
stateString,
|
||||
allPortsString
|
||||
] = line.split(/\s{3,}/)
|
||||
|
||||
return {
|
||||
name: nameString.trim(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue