From e223c289f75c6e5326b16e3f196823ce924b47f1 Mon Sep 17 00:00:00 2001 From: Kien La Date: Wed, 18 Sep 2024 22:44:07 -0400 Subject: [PATCH] filter ps on context --- src/docker.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/docker.ts b/src/docker.ts index a064ab6..ade4f78 100644 --- a/src/docker.ts +++ b/src/docker.ts @@ -20,7 +20,9 @@ async function container(command: string) { * @returns An array of strings representing the Docker containers. */ function ps(context: string): Array> { - 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 {