buildx: printVersion

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2023-01-24 00:13:52 +01:00
parent 4f2a155c08
commit fe75972f55
No known key found for this signature in database
GPG Key ID: 3248E46B6BB8C7F7
3 changed files with 32 additions and 2 deletions

View File

@ -135,6 +135,29 @@ describe('isAvailable', () => {
});
});
describe('printVersion', () => {
it('docker cli', () => {
const execSpy = jest.spyOn(exec, 'exec');
const buildx = new Buildx({
standalone: false
});
buildx.printVersion();
expect(execSpy).toHaveBeenCalledWith(`docker`, ['buildx', 'version'], {
failOnStdErr: false
});
});
it('standalone', () => {
const execSpy = jest.spyOn(exec, 'exec');
const buildx = new Buildx({
standalone: true
});
buildx.printVersion();
expect(execSpy).toHaveBeenCalledWith(`buildx`, ['version'], {
failOnStdErr: false
});
});
});
describe('getVersion', () => {
it('valid', async () => {
const buildx = new Buildx();

View File

@ -17,7 +17,7 @@ describe('isAvailable', () => {
});
describe('printVersion', () => {
it('standard', () => {
it('docker cli', () => {
const execSpy = jest.spyOn(exec, 'exec');
Docker.printVersion(false);
expect(execSpy).toHaveBeenCalledWith(`docker`, ['version'], {
@ -34,7 +34,7 @@ describe('printVersion', () => {
});
describe('printInfo', () => {
it('standard', () => {
it('docker cli', () => {
const execSpy = jest.spyOn(exec, 'exec');
Docker.printInfo(false);
expect(execSpy).toHaveBeenCalledWith(`docker`, ['info'], {

View File

@ -71,6 +71,13 @@ export class Buildx {
});
}
public async printVersion() {
const cmd = this.getCommand(['version']);
await exec.exec(cmd.command, cmd.args, {
failOnStdErr: false
});
}
public static parseVersion(stdout: string): string {
const matches = /\sv?([0-9a-f]{7}|[0-9.]+)/.exec(stdout);
if (!matches) {