buildx: dest dir optional on install

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2023-02-17 23:54:28 +01:00
parent bb8a659d9e
commit 76e5a25cff
No known key found for this signature in database
GPG Key ID: 3248E46B6BB8C7F7

View File

@ -45,7 +45,7 @@ export class Install {
this.standalone = opts?.standalone ?? !Docker.isAvailable; this.standalone = opts?.standalone ?? !Docker.isAvailable;
} }
public async download(version: string, dest: string): Promise<string> { public async download(version: string, dest?: string): Promise<string> {
const release: GitHubRelease = await Install.getRelease(version); const release: GitHubRelease = await Install.getRelease(version);
const fversion = release.tag_name.replace(/^v+|v+$/g, ''); const fversion = release.tag_name.replace(/^v+|v+$/g, '');
@ -59,13 +59,14 @@ export class Install {
toolPath = await this.fetchBinary(fversion); toolPath = await this.fetchBinary(fversion);
} }
dest = dest || (this.standalone ? this.context.tmpDir() : Docker.configDir);
if (this.standalone) { if (this.standalone) {
return this.setStandalone(toolPath, dest); return this.setStandalone(toolPath, dest);
} }
return this.setPlugin(toolPath, dest); return this.setPlugin(toolPath, dest);
} }
public async build(gitContext: string, dest: string): Promise<string> { public async build(gitContext: string, dest?: string): Promise<string> {
// eslint-disable-next-line prefer-const // eslint-disable-next-line prefer-const
let [repo, ref] = gitContext.split('#'); let [repo, ref] = gitContext.split('#');
if (ref.length == 0) { if (ref.length == 0) {
@ -98,6 +99,7 @@ export class Install {
}); });
} }
dest = dest || Docker.configDir;
if (this.standalone) { if (this.standalone) {
return this.setStandalone(toolPath, dest); return this.setStandalone(toolPath, dest);
} }