Skip to content

Commit f78f708

Browse files
authored
Merge pull request #57 from crazy-max/fix-docker-context
docker: fix context command
2 parents 1cc5fc8 + 6fe7d54 commit f78f708

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

__tests__/docker.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe('context', () => {
6363
await Docker.context().catch(() => {
6464
// noop
6565
});
66-
expect(execSpy).toHaveBeenCalledWith(`docker`, ['context', 'show'], {
66+
expect(execSpy).toHaveBeenCalledWith(`docker`, ['context', 'inspect', '--format', '{{.Name}}'], {
6767
ignoreReturnCode: true,
6868
silent: true
6969
});

src/docker.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,12 @@ export class Docker {
3838
});
3939
}
4040

41-
public static async context(): Promise<string> {
42-
return await Exec.getExecOutput(`docker`, ['context', 'show'], {
41+
public static async context(name?: string): Promise<string> {
42+
const args = ['context', 'inspect', '--format', '{{.Name}}'];
43+
if (name) {
44+
args.push(name);
45+
}
46+
return await Exec.getExecOutput(`docker`, args, {
4347
ignoreReturnCode: true,
4448
silent: true
4549
}).then(res => {

0 commit comments

Comments
 (0)