mirror of
https://github.com/danbulant/docker-compose
synced 2026-06-24 17:31:53 +00:00
feat: allow passing service names to rm function
This commit is contained in:
parent
dc5bf430ff
commit
3a68db75e3
4 changed files with 4230 additions and 2530 deletions
6733
package-lock.json
generated
6733
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -70,6 +70,7 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "^8.2.0",
|
"@commitlint/cli": "^8.2.0",
|
||||||
"@commitlint/config-conventional": "^8.2.0",
|
"@commitlint/config-conventional": "^8.2.0",
|
||||||
|
"@types/dockerode": "^2.5.27",
|
||||||
"@types/jest": "^25.1.4",
|
"@types/jest": "^25.1.4",
|
||||||
"@types/node": "^10.17.17",
|
"@types/node": "^10.17.17",
|
||||||
"@typescript-eslint/eslint-plugin": "^2.23.0",
|
"@typescript-eslint/eslint-plugin": "^2.23.0",
|
||||||
|
|
|
||||||
|
|
@ -150,8 +150,8 @@ export const kill = function (options?: IDockerComposeOptions): Promise<IDockerC
|
||||||
return execCompose('kill', [], options);
|
return execCompose('kill', [], options);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const rm = function (options?: IDockerComposeOptions): Promise<IDockerComposeResult> {
|
export const rm = function (options?: IDockerComposeOptions, ...services: string[]): Promise<IDockerComposeResult> {
|
||||||
return execCompose('rm', [ '-f' ], options);
|
return execCompose('rm', [ '-f', ...services ], options);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const exec = function (container: string, command: string | string[], options?: IDockerComposeOptions): Promise<IDockerComposeResult> {
|
export const exec = function (container: string, command: string | string[], options?: IDockerComposeOptions): Promise<IDockerComposeResult> {
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ const isContainerRunning = async (name: string): Promise<boolean> => new Promise
|
||||||
reject(err);
|
reject(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
const running = containers.filter((container): boolean => container.Names.includes(name));
|
const running = (containers || []).filter((container): boolean => container.Names.includes(name));
|
||||||
|
|
||||||
resolve(running.length > 0);
|
resolve(running.length > 0);
|
||||||
});
|
});
|
||||||
|
|
@ -523,6 +523,26 @@ test('returns the port for a started service', async (): Promise<void> => {
|
||||||
await compose.down(config);
|
await compose.down(config);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('removes container', async (): Promise<void> => {
|
||||||
|
const config = {
|
||||||
|
cwd: path.join(__dirname),
|
||||||
|
config: './docker-compose.yml',
|
||||||
|
log: logOutput
|
||||||
|
};
|
||||||
|
|
||||||
|
await compose.upAll(config);
|
||||||
|
expect(await isContainerRunning('/compose_test_nginx')).toBeTruthy();
|
||||||
|
expect(await isContainerRunning('/compose_test_alpine')).toBeTruthy();
|
||||||
|
|
||||||
|
await compose.rm({ ...config, commandOptions: ['-s'] }, 'alpine');
|
||||||
|
expect(await isContainerRunning('/compose_test_nginx')).toBeTruthy();
|
||||||
|
expect(await isContainerRunning('/compose_test_alpine')).toBeFalsy();
|
||||||
|
|
||||||
|
await compose.rm({ ...config, commandOptions: ['-s'] }, 'alpine', 'db');
|
||||||
|
expect(await isContainerRunning('/compose_test_nginx')).toBeFalsy();
|
||||||
|
expect(await isContainerRunning('/compose_test_alpine')).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
test('returns version information', async (): Promise<void> => {
|
test('returns version information', async (): Promise<void> => {
|
||||||
const version = await compose.version();
|
const version = await compose.version();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue