Skip to content

Commit

Permalink
fix: ps --services trim on undefined (#201)
Browse files Browse the repository at this point in the history
Co-authored-by: Jenkins <[email protected]>
  • Loading branch information
gamaraan and Jenkins authored Jan 17, 2022
1 parent 4566d1a commit 5df547e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ export const mapPsOutput = (
if (options?.commandOptions) {
isQuiet =
options.commandOptions.includes('-q') ||
options.commandOptions.includes('--quiet')
options.commandOptions.includes('--quiet') ||
options.commandOptions.includes('--services')
}
const services = output
.split(`\n`)
Expand Down
25 changes: 25 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,31 @@ f49548fa0b1f88846b78c65c6ea7f802bcbdfb2cf10204497eb89ba622d7715b
)
})

test('ps returns container names when --services is passed in options', () => {
const output = `web
proxy
hello
`
const psOut = mapPsOutput(output, { commandOptions: ['--services'] })
expect(psOut.services[0]).toEqual(
expect.objectContaining({
name: 'web'
})
)

expect(psOut.services[1]).toEqual(
expect.objectContaining({
name: 'proxy'
})
)

expect(psOut.services[2]).toEqual(
expect.objectContaining({
name: 'hello'
})
)
})

test('ensure progress callback is called', async (): Promise<void> => {
const config = {
cwd: path.join(__dirname),
Expand Down

0 comments on commit 5df547e

Please sign in to comment.