mirror of
https://github.com/danbulant/docker-compose
synced 2026-06-14 20:21:39 +00:00
Merge pull request #34 from falinsky/feature/add-ps-command
Provide ability to run docker-compose ps command
This commit is contained in:
commit
40540703c0
4 changed files with 40 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 };
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ npm install --save-dev docker-compose
|
|||
* `buildAll(options)` - Build or rebuild services
|
||||
* `buildMany(services, options)` - Build or rebuild services
|
||||
* `buildOne(service, options)` - Build or rebuild service
|
||||
* `ps(options)` - Lists containers information
|
||||
|
||||
All commands return a `Promise({object})` with an stdout and stderr strings
|
||||
```javascript
|
||||
|
|
|
|||
|
|
@ -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