mirror of
https://github.com/docker/actions-toolkit.git
synced 2024-11-26 22:26:08 +08:00
buildx: optional version for versionSatisfies
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
b6f85576fa
commit
d27b5d60be
@ -191,7 +191,8 @@ describe('versionSatisfies', () => {
|
||||
['bda4882a65349ca359216b135896bddc1d92461c', '>0.1.0', false],
|
||||
['f117971', '>0.6.0', true]
|
||||
])('given %p', async (version, range, expected) => {
|
||||
expect(Buildx.versionSatisfies(version, range)).toBe(expected);
|
||||
const buildx = new Buildx();
|
||||
expect(await buildx.versionSatisfies(range, version)).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -86,8 +86,9 @@ export class Buildx {
|
||||
return matches[1];
|
||||
}
|
||||
|
||||
public static versionSatisfies(version: string, range: string): boolean {
|
||||
return semver.satisfies(version, range) || /^[0-9a-f]{7}$/.exec(version) !== null;
|
||||
public async versionSatisfies(range: string, version?: string): Promise<boolean> {
|
||||
const ver = version ?? (await this.getVersion());
|
||||
return semver.satisfies(ver, range) || /^[0-9a-f]{7}$/.exec(ver) !== null;
|
||||
}
|
||||
|
||||
public getBuildImageIDFilePath(): string {
|
||||
|
Loading…
Reference in New Issue
Block a user