fix: handle 'latest' version
Some checks failed
Check Transpiled JavaScript / Check dist/ (push) Has been cancelled
Continuous Integration / TypeScript Tests (push) Has been cancelled
Continuous Integration / GitHub Actions Test (push) Has been cancelled

This commit is contained in:
Peter 2024-05-02 19:36:40 +02:00
parent 045c79efbf
commit 4431e4a952
Signed by: prskr
GPG key ID: F56BED6903BC5E37
4 changed files with 14 additions and 13 deletions

View file

@ -15,7 +15,7 @@ describe('Asset lookup', () => {
const release = await octoVersionDetermination.getRelease(
Hugo.Org,
Hugo.Repo,
'',
'latest',
HugoReleaseTransformer
)
expect(release.tag_name).toMatch(new RegExp('\\d+.\\d+.\\d+'))

2
dist/index.js vendored
View file

@ -49221,7 +49221,7 @@ class OctokitReleaseLookup {
this.octokit = new dist_node.Octokit({ auth: pat });
}
async getRelease(owner, repo, version, transformer) {
const latestRelease = version
const latestRelease = version && version !== 'latest'
? await this.octokit.rest.repos.getReleaseByTag({
owner: owner,
repo: repo,

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View file

@ -31,16 +31,17 @@ export class OctokitReleaseLookup implements IReleaseLookup {
version: string | undefined,
transformer: IReleaseTransformer<T>
): Promise<T> {
const latestRelease = version
? await this.octokit.rest.repos.getReleaseByTag({
owner: owner,
repo: repo,
tag: version
})
: await this.octokit.rest.repos.getLatestRelease({
owner: owner,
repo: repo
})
const latestRelease =
version && version !== 'latest'
? await this.octokit.rest.repos.getReleaseByTag({
owner: owner,
repo: repo,
tag: version
})
: await this.octokit.rest.repos.getLatestRelease({
owner: owner,
repo: repo
})
return transformer.map(latestRelease.data)
}
}