Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
75 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,38 @@ | ||
import * as semver from 'semver'; | ||
import * as exec from './exec'; | ||
import * as exec from '@actions/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; | ||
}); | ||
return await exec | ||
.getExecOutput('docker', ['buildx'], { | ||
ignoreReturnCode: true, | ||
silent: true | ||
}) | ||
.then(res => { | ||
if (res.stderr.length > 0 && res.exitCode != 0) { | ||
return false; | ||
} | ||
return res.exitCode == 0; | ||
}); | ||
} | ||
|
||
export async function getVersion(): Promise<string> { | ||
return await exec.exec(`docker`, ['buildx', 'version'], true).then(res => { | ||
if (res.stderr != '' && !res.success) { | ||
throw new Error(res.stderr); | ||
} | ||
return parseVersion(res.stdout); | ||
}); | ||
return await exec | ||
.getExecOutput('docker', ['buildx', 'version'], { | ||
ignoreReturnCode: true, | ||
silent: true | ||
}) | ||
.then(res => { | ||
if (res.stderr.length > 0 && res.exitCode != 0) { | ||
throw new Error(res.stderr); | ||
} | ||
return parseVersion(res.stdout); | ||
}); | ||
} | ||
|
||
export async function parseVersion(stdout: string): Promise<string> { | ||
const matches = /\sv?([0-9.]+)/.exec(stdout); | ||
if (!matches) { | ||
throw new Error(`Cannot parse Buildx version`); | ||
throw new Error(`Cannot parse buildx version`); | ||
} | ||
return semver.clean(matches[1]); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters