1
0
mirror of https://github.com/docker/setup-qemu-action.git synced 2025-07-08 14:12:48 +08:00
setup-qemu-action/src/qemu.ts
CrazyMax 3bf7a4ebec
display QEMU version installed on the runner
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-01-05 12:14:37 +01:00

40 lines
814 B
TypeScript

import os from 'os';
import * as core from '@actions/core';
import * as io from '@actions/io';
import {Exec} from '@docker/actions-toolkit/lib/exec';
export async function isInstalled(): Promise<boolean> {
return await io
.which(bin(), true)
.then(res => {
core.debug(`qemu.isInstalled ok: ${res}`);
return true;
})
.catch(error => {
core.debug(`qemu.isInstalled error: ${error}`);
return false;
});
}
export async function printVersion(): Promise<void> {
await Exec.exec(bin(), ['--version']);
}
export function bin(): string {
return `qemu-system-${arch()}`;
}
function arch(): string {
switch (os.arch()) {
case 'x64': {
return 'x86_64';
}
case 'arm64': {
return 'aarch64';
}
default: {
return os.arch();
}
}
}