authelia/test/helpers/context/DockerCompose.ts
2019-03-03 11:39:40 +01:00

28 lines
675 B
TypeScript

import { exec } from '../../helpers/utils/exec';
import { execSync } from 'child_process';
class DockerCompose {
private commandPrefix: string;
constructor(composeFiles: string[]) {
this.commandPrefix = 'docker-compose ' + composeFiles.map((f) => '-f ' + f).join(' ');
}
async up() {
return await exec(this.commandPrefix + ' up -d');
}
async down() {
return await exec(this.commandPrefix + ' down');
}
async restart(service: string) {
return await exec(this.commandPrefix + ' restart ' + service);
}
async ps() {
return Promise.resolve(execSync(this.commandPrefix + ' ps').toString('utf-8'));
}
}
export default DockerCompose;