From 8d9b3e5684608c281227452a9618926849952b18 Mon Sep 17 00:00:00 2001 From: Kien La Date: Mon, 2 Dec 2024 17:49:17 -0500 Subject: [PATCH] add missing awaits --- src/app.ts | 4 ++-- src/container.ts | 30 +++++++++++++++--------------- src/docker.ts | 6 +++--- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/app.ts b/src/app.ts index b4ba2a1..ffa94f5 100644 --- a/src/app.ts +++ b/src/app.ts @@ -114,11 +114,11 @@ export default class App { } async down() { - return docker.compose(this.context, 'stop', this.composeFile) + return await docker.compose(this.context, 'stop', this.composeFile) } async up() { - return docker.compose(this.context, 'start', this.composeFile, { exit: true }) + return await docker.compose(this.context, 'start', this.composeFile, { exit: true }) } async remove() { diff --git a/src/container.ts b/src/container.ts index 98a207d..419f4f8 100644 --- a/src/container.ts +++ b/src/container.ts @@ -136,15 +136,15 @@ export default class Container { } async down() { - return docker.compose(this.context, `stop ${this.name}`, this.composeFile) + return await docker.compose(this.context, `stop ${this.name}`, this.composeFile) } async up() { - return docker.compose(this.context, `start ${this.name}`, this.composeFile, { exit: true }) + return await docker.compose(this.context, `start ${this.name}`, this.composeFile, { exit: true }) } async remove() { - return docker.compose(this.context, 'rm --stop --force --volumes', this.composeFile) + return await docker.compose(this.context, 'rm --stop --force --volumes', this.composeFile) } async exec(command: string, options: RunOptions = {}) { @@ -153,8 +153,8 @@ export default class Container { linkSshAuthSock() if (this.running) - return docker.container(`exec ${args} ${this.containerName} ${command}`, options) - return docker.compose(this.context, `run --rm ${args} ${this.name} ${command}`, this.composeFile, options) + return await docker.container(`exec ${args} ${this.containerName} ${command}`, options) + return await docker.compose(this.context, `run --rm ${args} ${this.name} ${command}`, this.composeFile, options) } async rebuild(config: StaxConfig, options: SetupOptions = {}) { @@ -165,7 +165,7 @@ export default class Container { context: this.context, source: this.source, staxfile: this.staxfile } - App.setup(config, { ...options, rebuild: true }) + await App.setup(config, { ...options, rebuild: true }) } async shell() { @@ -190,24 +190,24 @@ export default class Container { if (options.tail) command += ` --tail=${options.tail}` if (!options.since) options.since = '10m' if (options.since) command += ` --since=${options.since}` - return docker.compose(this.context, command, this.composeFile) + return await docker.compose(this.context, command, this.composeFile) } async restart() { - return docker.compose(this.context, `restart ${this.name}`, this.composeFile) + return await docker.compose(this.context, `restart ${this.name}`, this.composeFile) } async runHook(type) { - [ '', '.host' ].forEach((location) => { + for (const location of ['', '.host']) { let hook = this.labels[`stax.${type}${location}`] - if (!hook) return + if (!hook) continue if (existsSync(hook)) { const command = location === '.host' ? hook : `cat ${hook} | docker container exec --interactive ${this.containerName} /bin/sh` - run(command) + await run(command) } else - run(hook) - }) + await run(hook) + } } async copy(source: string, destination: string, options: { dontOverwrite?: boolean } = {}) { @@ -231,10 +231,10 @@ export default class Container { return } - docker.container(`cp ${source} ${this.containerName}:${destPath}`) + await docker.container(`cp ${source} ${this.containerName}:${destPath}`) } async get(source, destination) { - return docker.container(`cp ${this.containerName}:${source} ${destination}`) + return await docker.container(`cp ${this.containerName}:${source} ${destination}`) } } diff --git a/src/docker.ts b/src/docker.ts index d3d9f07..35c6c42 100644 --- a/src/docker.ts +++ b/src/docker.ts @@ -9,11 +9,11 @@ async function compose(context: string, command: string, composeFile: string, op options = { append: true, ...options, env: { COMPOSE_IGNORE_ORPHANS: "1" } } options.exit && verifyFile(composeFile) - return run(`${base} -f ${composeFile} ${command}`, options as unknown as RunOptions) + return await run(`${base} -f ${composeFile} ${command}`, options as unknown as RunOptions) } async function container(command: string, options: RunOptions = {}) { - return run(`docker container ${command}`, options) + return await run(`docker container ${command}`, options) } /** @@ -54,7 +54,7 @@ function volumeExists(volume: string): boolean { } async function volumeRemove(volume: string) { - return run(`docker volume rm "${volume}"`) + return await run(`docker volume rm "${volume}"`) } const inspectCache: Record> = {}