mirror of
https://github.com/danbulant/docker-compose
synced 2026-05-22 05:48:48 +00:00
Merge pull request #90 from Steveb-p/add-pull
Add pullOne, pullMany and pullAll methods
This commit is contained in:
commit
bdd539ce8f
2 changed files with 65 additions and 0 deletions
12
src/index.ts
12
src/index.ts
|
|
@ -172,6 +172,18 @@ export const buildOne = function (service: string, options?: IDockerComposeBuild
|
|||
return execCompose('build', [ service ], options);
|
||||
};
|
||||
|
||||
export const pullAll = function (options: IDockerComposeOptions = {}): Promise<IDockerComposeResult> {
|
||||
return execCompose('pull', [], options);
|
||||
};
|
||||
|
||||
export const pullMany = function (services: string[], options: IDockerComposeOptions = {}): Promise<IDockerComposeResult> {
|
||||
return execCompose('pull', services, options);
|
||||
};
|
||||
|
||||
export const pullOne = function (service: string, options?: IDockerComposeOptions): Promise<IDockerComposeResult> {
|
||||
return execCompose('pull', [ service ], options);
|
||||
};
|
||||
|
||||
export const config = function (options?: IDockerComposeOptions): Promise<IDockerComposeResult> {
|
||||
return execCompose('config', [], options);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -323,6 +323,59 @@ test('build all services', async (): Promise<void> => {
|
|||
await removeImagesStartingWith('compose-test-build-image');
|
||||
});
|
||||
|
||||
test('pull single service', async (): Promise<void> => {
|
||||
const opts = {
|
||||
cwd: path.join(__dirname),
|
||||
log: logOutput,
|
||||
config: 'docker-compose.yml'
|
||||
};
|
||||
|
||||
await removeImagesStartingWith('nginx:1.16.0');
|
||||
expect(await imageExists('nginx:1.16.0')).toBeFalsy();
|
||||
|
||||
await compose.pullOne('db', opts);
|
||||
|
||||
expect(await imageExists('nginx:1.16.0')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('pull multiple services', async (): Promise<void> => {
|
||||
const opts = {
|
||||
cwd: path.join(__dirname),
|
||||
log: logOutput,
|
||||
config: 'docker-compose.yml'
|
||||
};
|
||||
|
||||
await removeImagesStartingWith('nginx:1.16.0');
|
||||
await removeImagesStartingWith('alpine:3.7.3');
|
||||
|
||||
expect(await imageExists('nginx:1.16.0')).toBeFalsy();
|
||||
expect(await imageExists('alpine:3.7.3')).toBeFalsy();
|
||||
|
||||
await compose.pullMany([ 'db', 'alpine' ], opts);
|
||||
|
||||
expect(await imageExists('nginx:1.16.0')).toBeTruthy();
|
||||
expect(await imageExists('alpine:3.7.3')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('pull all services', async (): Promise<void> => {
|
||||
const opts = {
|
||||
cwd: path.join(__dirname),
|
||||
log: logOutput,
|
||||
config: 'docker-compose.yml'
|
||||
};
|
||||
|
||||
await removeImagesStartingWith('nginx:1.16.0');
|
||||
await removeImagesStartingWith('alpine:3.7.3');
|
||||
|
||||
expect(await imageExists('nginx:1.16.0')).toBeFalsy();
|
||||
expect(await imageExists('alpine:3.7.3')).toBeFalsy();
|
||||
|
||||
await compose.pullAll(opts);
|
||||
|
||||
expect(await imageExists('nginx:1.16.0')).toBeTruthy();
|
||||
expect(await imageExists('alpine:3.7.3')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('teardown', async (): Promise<void> => {
|
||||
interface Container {
|
||||
Names: string[];
|
||||
|
|
|
|||
Loading…
Reference in a new issue