Skip to content

Commit

Permalink
use run or exec
Browse files Browse the repository at this point in the history
  • Loading branch information
kla committed Sep 8, 2024
1 parent 1f3d032 commit 052e4d3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ export default class Container {
}

async exec(command: string) {
return docker.container(`exec --interactive --tty ${this.containerName} ${command}`)
}
const args = '--interactive --tty'

async run(command: string) {
return docker.compose(this.context, `run --rm ${this.name} ${command}`, this.composeFile)
if (this.running)
return docker.container(`exec ${args} ${this.containerName} ${command}`)
return docker.compose(this.context, `run --rm ${args} ${this.name} ${command}`, this.composeFile)
}

async rebuild(config: StaxConfig, options: SetupOptions = {}) {
Expand All @@ -155,7 +155,7 @@ export default class Container {
const shells = [ '/bin/bash', '/bin/sh' ]
shells.find(async (shell) => {
try {
await this[this.running ? 'exec' : 'run'](shell)
await this.exec(shell)
return true
} catch (e) {
return false
Expand Down

0 comments on commit 052e4d3

Please sign in to comment.