fix: use async/await for exec

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
This commit is contained in:
Jeroen de Bruijn 2020-05-04 06:55:28 +01:00 committed by GitHub
parent b435cadb65
commit cd7e423dd8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -20,28 +20,20 @@ class Renovate {
}
runDockerContainer(): Promise<void> {
return new Promise((resolve, reject) => {
const commandArguments = [
'--rm',
`--env ${this.configFileEnv}=${this.configFileMountPath()}`,
`--env ${this.tokenEnv}=${this.token}`,
`--volume ${this.configFile}:${this.configFileMountPath()}`,
this.docker.image(),
];
const command = `docker run ${commandArguments.join(' ')}`;
exec(command)
.then((code) => {
if (code === 0) {
resolve();
} else {
reject(new Error(`'docker run' failed with exit code ${code}.`));
}
})
.catch((error) => {
reject(error);
});
});
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);
if (code !== 0) {
new Error(`'docker run' failed with exit code ${code}.`);
}
}
private validateArguments(): void {