3
0
Fork 0
mirror of https://gitea.com/docker/build-push-action.git synced 2024-11-29 21:09:36 +01:00
docker-build-push/src/buildx.ts
CrazyMax f7cac3b071
Refactor Docker config
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2020-08-16 02:37:47 +02:00

24 lines
697 B
TypeScript

import * as docker from './docker';
import * as exec from './exec';
export async function isAvailable(): Promise<Boolean> {
return await exec.exec(`docker`, ['buildx'], true).then(res => {
if (res.stderr != '' && !res.success) {
return false;
}
return res.success;
});
}
export async function isInstalled(): Promise<Boolean> {
const dockerCfg = await docker.config();
return dockerCfg?.aliases?.builder == 'buildx';
}
export async function use(builder: string): Promise<void> {
return await exec.exec(`docker`, ['buildx', 'use', '--builder', builder], false).then(res => {
if (res.stderr != '' && !res.success) {
throw new Error(res.stderr);
}
});
}