import { StartedGenericContainer } from "../generic-container/started-generic-container" ; import { log } from "../logger" ; import { dockerComposeDown } from "../docker-compose/functions/docker-compose-down" ; import { dockerComposeStop } from "../docker-compose/functions/docker-compose-stop" ; import { StoppedDockerComposeEnvironment } from "./stopped-docker-compose-environment" ; import { DownedDockerComposeEnvironment } from "./downed-docker-compose-environment" ; import { DockerComposeOptions } from "../docker-compose/docker-compose-options" ; export class StartedDockerComposeEnvironment { constructor ( private readonly startedGenericContainers , private readonly options ) { } public async stop ( ) { await dockerComposeStop ( this . options ) ; return new StoppedDockerComposeEnvironment ( this . options ) ; } public async down ( ) { await dockerComposeDown ( this . options ) ; return new DownedDockerComposeEnvironment ( ) ; } public getContainer ( containerName ) { const container = this . startedGenericContainers [ containerName ] ; if ( ! container ) { const error = `Cannot get container "${ containerName }" as it is not running` ; log . error ( error ) ; throw new Error ( error ) ; } return container ; } }