2020-08-16 00:37:47 +00:00
|
|
|
import * as docker from './docker';
|
2020-08-15 22:36:41 +00:00
|
|
|
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;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-08-16 00:30:03 +00:00
|
|
|
export async function isInstalled(): Promise<Boolean> {
|
2020-08-16 00:37:47 +00:00
|
|
|
const dockerCfg = await docker.config();
|
|
|
|
return dockerCfg?.aliases?.builder == 'buildx';
|
2020-08-16 00:30:03 +00:00
|
|
|
}
|
|
|
|
|
2020-08-15 22:36:41 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|