mirror of
https://github.com/docker/actions-toolkit.git
synced 2024-11-23 03:16:09 +08:00
buildx: check standalone
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
595e2417e8
commit
1b8e89676e
@ -6,6 +6,8 @@ import {parse} from 'csv-parse/sync';
|
||||
import * as semver from 'semver';
|
||||
import * as tmp from 'tmp';
|
||||
|
||||
import {Docker} from './docker';
|
||||
|
||||
export interface BuildxOpts {
|
||||
standalone?: boolean;
|
||||
}
|
||||
@ -16,10 +18,22 @@ export class Buildx {
|
||||
private tmpdir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-actions-toolkit-')).split(path.sep).join(path.posix.sep);
|
||||
|
||||
constructor(opts?: BuildxOpts) {
|
||||
this.standalone = opts?.standalone ?? false;
|
||||
this.standalone = opts?.standalone ?? this.isStandalone();
|
||||
this.version = this.getVersion();
|
||||
}
|
||||
|
||||
private isStandalone(): boolean {
|
||||
let dockerAvailable = false;
|
||||
Docker.isAvailable()
|
||||
.then((res: boolean) => {
|
||||
dockerAvailable = res;
|
||||
})
|
||||
.catch(e => {
|
||||
dockerAvailable = false;
|
||||
});
|
||||
return dockerAvailable;
|
||||
}
|
||||
|
||||
public getCommand(args: Array<string>) {
|
||||
return {
|
||||
command: this.standalone ? 'buildx' : 'docker',
|
||||
|
Loading…
Reference in New Issue
Block a user