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