()
| 22 | static args = Command.args |
| 23 | |
| 24 | async run(): Promise<void> { |
| 25 | try { |
| 26 | const { |
| 27 | flags: { 'delete-image': rmContainer }, |
| 28 | } = await this.parse(Teardown) |
| 29 | let containerToRemove: undefined | string |
| 30 | const runningContainerId = await findExistingDGraphContainerId('running') |
| 31 | this.logger.startSpinner('Stopping Dgraph container...') |
| 32 | if (runningContainerId) { |
| 33 | await execCommand(`docker stop ${runningContainerId}`) |
| 34 | this.logger.successSpinner( |
| 35 | `Dgraph container(${runningContainerId}) stopped successfully!` |
| 36 | ) |
| 37 | containerToRemove = runningContainerId |
| 38 | } else { |
| 39 | const exitedContainerId = await findExistingDGraphContainerId('exited') |
| 40 | if (exitedContainerId && exitedContainerId !== '') { |
| 41 | this.logger.successSpinner( |
| 42 | `Existing Dgraph container(${exitedContainerId}) is already stopped!` |
| 43 | ) |
| 44 | containerToRemove = exitedContainerId |
| 45 | } else { |
| 46 | this.logger.successSpinner('No Dgraph containers found!') |
| 47 | } |
| 48 | } |
| 49 | if (rmContainer && containerToRemove) { |
| 50 | this.logger.startSpinner( |
| 51 | `Removing Dgraph container(${containerToRemove})...` |
| 52 | ) |
| 53 | await execCommand(`docker rm ${containerToRemove}`) |
| 54 | this.logger.successSpinner( |
| 55 | `Dgraph container(${containerToRemove}) removed successfully` |
| 56 | ) |
| 57 | } |
| 58 | } catch (error: any) { |
| 59 | this.logger.failSpinner('Error while stopping dgraph container') |
| 60 | this.logger.debug(error) |
| 61 | } |
| 62 | } |
| 63 | } |
nothing calls this directly
no test coverage detected