From 052e4d3afb7ba1af5135aa5b951dcbf4beb7076b Mon Sep 17 00:00:00 2001 From: Kien La Date: Sun, 8 Sep 2024 14:02:09 -0400 Subject: [PATCH] use run or exec --- src/container.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/container.ts b/src/container.ts index eb896b5..3e845e4 100644 --- a/src/container.ts +++ b/src/container.ts @@ -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 = {}) { @@ -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