Skip to content

Commit

Permalink
filter ps on context
Browse files Browse the repository at this point in the history
  • Loading branch information
kla committed Sep 19, 2024
1 parent 5257c44 commit e223c28
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ async function container(command: string) {
* @returns An array of strings representing the Docker containers.
*/
function ps(context: string): Array<Record<string,any>> {
return capture('docker ps --all --format json').split("\n").map(attributes => JSON.parse(attributes))
return capture('docker ps --all --format json').split("\n")
.map(attributes => attributes.includes(`com.docker.compose.project=${context}`) ? JSON.parse(attributes) : null)
.filter(Boolean)
}

function fileExists(containerName: string, path: string): boolean {
Expand Down

0 comments on commit e223c28

Please sign in to comment.