diff --git a/__tests__/docker.test.ts b/__tests__/docker.test.ts index ec14466..8933fd2 100644 --- a/__tests__/docker.test.ts +++ b/__tests__/docker.test.ts @@ -16,19 +16,36 @@ describe('isAvailable', () => { }); }); -describe('info', () => { +describe('printVersion', () => { it('standard', () => { const execSpy = jest.spyOn(exec, 'exec'); - Docker.info(false); + Docker.printVersion(false); expect(execSpy).toHaveBeenCalledWith(`docker`, ['version'], { failOnStdErr: false }); }); it('standalone', () => { const execSpy = jest.spyOn(exec, 'exec'); - Docker.info(true); + Docker.printVersion(true); expect(execSpy).not.toHaveBeenCalledWith(`docker`, ['version'], { failOnStdErr: false }); }); }); + +describe('printInfo', () => { + it('standard', () => { + const execSpy = jest.spyOn(exec, 'exec'); + Docker.printInfo(false); + expect(execSpy).toHaveBeenCalledWith(`docker`, ['info'], { + failOnStdErr: false + }); + }); + it('standalone', () => { + const execSpy = jest.spyOn(exec, 'exec'); + Docker.printInfo(true); + expect(execSpy).not.toHaveBeenCalledWith(`docker`, ['info'], { + failOnStdErr: false + }); + }); +}); diff --git a/src/docker.ts b/src/docker.ts index 1da940f..6d77c8b 100644 --- a/src/docker.ts +++ b/src/docker.ts @@ -1,4 +1,3 @@ -import * as core from '@actions/core'; import * as exec from '@actions/exec'; export class Docker { @@ -23,17 +22,23 @@ export class Docker { return dockerAvailable; } - public static async info(standalone?: boolean) { - const dockerAvailable = standalone ?? !Docker.isAvailable(); - if (dockerAvailable) { - core.info(`Docker info skipped in standalone mode`); - } else { - await exec.exec('docker', ['version'], { - failOnStdErr: false - }); - await exec.exec('docker', ['info'], { - failOnStdErr: false - }); + public static async printVersion(standalone?: boolean) { + const noDocker = standalone ?? !Docker.isAvailable(); + if (noDocker) { + return; } + await exec.exec('docker', ['version'], { + failOnStdErr: false + }); + } + + public static async printInfo(standalone?: boolean) { + const noDocker = standalone ?? !Docker.isAvailable(); + if (noDocker) { + return; + } + await exec.exec('docker', ['info'], { + failOnStdErr: false + }); } }