Merge pull request #56 from crazy-max/docker-context
Some checks failed
publish / publish (push) Has been cancelled
Some checks failed
publish / publish (push) Has been cancelled
docker: context method
This commit is contained in:
@@ -57,6 +57,19 @@ describe('isAvailable', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('context', () => {
|
||||||
|
it('call docker context show', async () => {
|
||||||
|
const execSpy = jest.spyOn(Exec, 'getExecOutput');
|
||||||
|
await Docker.context().catch(() => {
|
||||||
|
// noop
|
||||||
|
});
|
||||||
|
expect(execSpy).toHaveBeenCalledWith(`docker`, ['context', 'show'], {
|
||||||
|
ignoreReturnCode: true,
|
||||||
|
silent: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('printVersion', () => {
|
describe('printVersion', () => {
|
||||||
it('call docker version', async () => {
|
it('call docker version', async () => {
|
||||||
const execSpy = jest.spyOn(Exec, 'exec');
|
const execSpy = jest.spyOn(Exec, 'exec');
|
||||||
|
|||||||
@@ -38,6 +38,18 @@ export class Docker {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async context(): Promise<string> {
|
||||||
|
return await Exec.getExecOutput(`docker`, ['context', 'show'], {
|
||||||
|
ignoreReturnCode: true,
|
||||||
|
silent: true
|
||||||
|
}).then(res => {
|
||||||
|
if (res.stderr.length > 0 && res.exitCode != 0) {
|
||||||
|
throw new Error(res.stderr);
|
||||||
|
}
|
||||||
|
return res.stdout.trim();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public static async printVersion(): Promise<void> {
|
public static async printVersion(): Promise<void> {
|
||||||
await Exec.exec('docker', ['version']);
|
await Exec.exec('docker', ['version']);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user