Skip to content

Commit

Permalink
fix: add fallback github release to tags
Browse files Browse the repository at this point in the history
  • Loading branch information
luthfimasruri committed Mar 23, 2021
1 parent 3bbf7d5 commit 186e025
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion docs/utils/github-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,21 @@ export const getLatestReleaseVersion = async (owner: string, repo: string): Prom
`https://api.github.com/repos/${owner}/${repo}/releases/latest`
)
.then((response) => response.json())
.then((data) => data.tag_name.replace("v", ""));
.then((data) => {
if (data.tag_name) {
return data.tag_name.replace("v", "")
} else {
return fetch(
`https://api.github.com/repos/${owner}/${repo}/tags`
)
.then((response) => response.json())
.then((data) => {
try {
return data[0].name.replace("v", "")
} catch {
return "latest"
}
})
}
})
};

0 comments on commit 186e025

Please sign in to comment.