docker: check command using actions/io module

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2023-02-21 08:40:27 +01:00
parent 3d9ec9f02d
commit 99487d6986
4 changed files with 12 additions and 19 deletions

View File

@@ -17,6 +17,7 @@
import os from 'os';
import path from 'path';
import * as core from '@actions/core';
import * as io from '@actions/io';
import {Exec} from './exec';
export class Docker {
@@ -25,24 +26,16 @@ export class Docker {
}
public static async isAvailable(): Promise<boolean> {
const ok: boolean = await Exec.getExecOutput('docker', [], {
ignoreReturnCode: true,
silent: true
})
return await io
.which('docker', true)
.then(res => {
if (res.stderr.length > 0 && res.exitCode != 0) {
core.debug(`Docker.isAvailable cmd err: ${res.stderr}`);
return false;
}
return res.exitCode == 0;
core.debug(`Docker.isAvailable ok: ${res}`);
return true;
})
.catch(error => {
core.debug(`Docker.isAvailable error: ${error}`);
return false;
});
core.debug(`Docker.isAvailable: ${ok}`);
return ok;
}
public static async printVersion(): Promise<void> {