mirror of
https://github.com/danbulant/docker-compose
synced 2026-06-10 02:02:49 +00:00
Provide ability to run docker-compose ps command
This commit is contained in:
parent
014482545a
commit
894f10281c
3 changed files with 39 additions and 1 deletions
1
index.d.ts
vendored
1
index.d.ts
vendored
|
|
@ -12,6 +12,7 @@ declare module "docker-compose" {
|
|||
buildAll(options: IDockerComposeOptions): Promise<IDockerComposeResult>;
|
||||
buildMany(services:String[], options: IDockerComposeOptions): Promise<IDockerComposeResult>;
|
||||
buildOne(service:String, options: IDockerComposeOptions): Promise<IDockerComposeResult>;
|
||||
ps(options: IDockerComposeOptions): Promise<IDockerComposeResult>;
|
||||
}
|
||||
|
||||
interface IDockerComposeOptions {
|
||||
|
|
|
|||
14
index.js
14
index.js
|
|
@ -221,4 +221,16 @@ const buildOne = function (service, options) {
|
|||
return execCompose('build', [ service ], options);
|
||||
};
|
||||
|
||||
module.exports = { upAll, upMany, upOne, kill, down, stop, rm, exec, run, buildAll, buildMany, buildOne };
|
||||
/**
|
||||
* Ps command
|
||||
* @param {object} options
|
||||
* @param {string} options.cwd
|
||||
* @param {boolean} [options.log]
|
||||
* @param {?(string|string[])} [options.config]
|
||||
* @param {?object} [options.env]
|
||||
*/
|
||||
const ps = function (options) {
|
||||
return execCompose('ps', [], options);
|
||||
};
|
||||
|
||||
module.exports = { upAll, upMany, upOne, kill, down, stop, rm, exec, run, buildAll, buildMany, buildOne, ps };
|
||||
|
|
|
|||
|
|
@ -220,3 +220,28 @@ test('teardown', async assert => {
|
|||
|
||||
assert.end();
|
||||
});
|
||||
|
||||
test('ps shows status data for started containers', async assert => {
|
||||
await compose.upAll({ cwd: path.join(__dirname), log: true });
|
||||
|
||||
const std = await compose.ps({ cwd: path.join(__dirname), log: true });
|
||||
|
||||
assert.false(std.err);
|
||||
assert.true(std.out.includes('compose_test_alpine'));
|
||||
assert.true(std.out.includes('compose_test_mongodb'));
|
||||
|
||||
assert.end();
|
||||
});
|
||||
|
||||
test('ps does not show status data for stopped containers', async assert => {
|
||||
await compose.down({ cwd: path.join(__dirname), log: true });
|
||||
await compose.upOne('alpine', { cwd: path.join(__dirname), log: true });
|
||||
|
||||
const std = await compose.ps({ cwd: path.join(__dirname), log: true });
|
||||
|
||||
assert.false(std.err);
|
||||
assert.true(std.out.includes('compose_test_alpine'));
|
||||
assert.false(std.out.includes('compose_test_mongodb'));
|
||||
|
||||
assert.end();
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue