Skip to content

Commit

Permalink
add missing awaits
Browse files Browse the repository at this point in the history
  • Loading branch information
kla committed Dec 2, 2024
1 parent 0ab9c6f commit 8d9b3e5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
30 changes: 15 additions & 15 deletions src/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}) {
Expand All @@ -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 = {}) {
Expand All @@ -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() {
Expand All @@ -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 } = {}) {
Expand All @@ -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}`)
}
}
6 changes: 3 additions & 3 deletions src/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

/**
Expand Down Expand Up @@ -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<string, Record<string, any>> = {}
Expand Down

0 comments on commit 8d9b3e5

Please sign in to comment.