diff --git a/__tests__/buildx.test.ts b/__tests__/buildx.test.ts index 6937d5a..0db98af 100644 --- a/__tests__/buildx.test.ts +++ b/__tests__/buildx.test.ts @@ -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); }); }); diff --git a/src/buildx.ts b/src/buildx.ts index 08f6d38..5056598 100644 --- a/src/buildx.ts +++ b/src/buildx.ts @@ -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 { + const ver = version ?? (await this.getVersion()); + return semver.satisfies(ver, range) || /^[0-9a-f]{7}$/.exec(ver) !== null; } public getBuildImageIDFilePath(): string {