Skip to content

Commit

Permalink
fix: πŸ› handle no service case with compose v2
Browse files Browse the repository at this point in the history
  • Loading branch information
polymath-eric committed Apr 8, 2024
1 parent 1613d95 commit 3d697b4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/common/containers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,12 @@ export async function containersUp(cmd: Command, verbose: boolean): Promise<stri
return matches![1];
});
} else if (composeVersion === 2) {
const services = JSON.parse(
execSync('docker-compose ps --format json', { cwd: localDir, stdio: 'pipe' }).toString()
);
const serviceResponse = execSync('docker-compose ps --format json', {
cwd: localDir,
stdio: 'pipe',
}).toString();

const services = serviceResponse ? JSON.parse(serviceResponse) : [];
return services.map((s: psServiceV2) => s.Service);
} else {
cmd.error(
Expand Down

0 comments on commit 3d697b4

Please sign in to comment.