mirror of
https://github.com/docker/actions-toolkit.git
synced 2024-11-23 03:16:09 +08:00
docker: split version and info
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
3c101c4aee
commit
4f2a155c08
@ -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
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -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 {
|
||||
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
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user