fix: use async/await in the runner

This commit is contained in:
Jeroen de Bruijn 2020-05-04 08:07:16 +02:00
parent cd7e423dd8
commit e300660370
No known key found for this signature in database
GPG key ID: 3A2677A1DF38FF9F
2 changed files with 14 additions and 13 deletions

View file

@ -2,14 +2,16 @@ import * as core from '@actions/core';
import Input from './input';
import Renovate from './renovate';
function run(): Promise<void> {
const input = new Input();
const renovate = new Renovate(input.configurationFile, input.token);
async function run(): Promise<void> {
try {
const input = new Input();
const renovate = new Renovate(input.configurationFile, input.token);
return renovate.runDockerContainer();
await renovate.runDockerContainer();
} catch (error) {
console.error(error);
core.setFailed(error.message);
}
}
run().catch((error) => {
console.error(error);
core.setFailed(error.message);
});
run();

View file

@ -19,18 +19,17 @@ class Renovate {
this.docker = new Docker();
}
runDockerContainer(): Promise<void> {
async runDockerContainer(): Promise<void> {
const commandArguments = [
'run',
'--rm',
`--env ${this.configFileEnv}=${this.configFileMountPath()}`,
`--env ${this.tokenEnv}=${this.token}`,
`--volume ${this.configFile}:${this.configFileMountPath()}`,
this.docker.image(),
];
const command = `docker`;
const code = exec(command, commandArguments);
const command = `docker run ${commandArguments.join(' ')}`;
const code = await exec(command);
if (code !== 0) {
new Error(`'docker run' failed with exit code ${code}.`);
}