authelia/test/helpers/context/DockerCompose.ts

32 lines
768 B
TypeScript
Raw Normal View History

import { exec } from '../../helpers/utils/exec';
2019-03-02 23:15:28 +07:00
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() {
2019-03-02 23:15:28 +07:00
return await exec(this.commandPrefix + ' up -d');
}
async down() {
2019-03-02 23:15:28 +07:00
return await exec(this.commandPrefix + ' down');
}
async restart(service: string) {
2019-03-02 23:15:28 +07:00
return await exec(this.commandPrefix + ' restart ' + service);
}
async ps() {
return Promise.resolve(execSync(this.commandPrefix + ' ps').toString('utf-8'));
}
async logs(service: string) {
await exec(this.commandPrefix + ' logs ' + service)
}
}
export default DockerCompose;