mirror of
https://github.com/softprops/action-gh-release.git
synced 2025-05-10 02:44:19 +00:00
refactor findTagFromReleases
purely a sytlistic choice to not have to pre-declare the _release variable, and not have to check using `typeof _release === "string"` when detecting a found release
This commit is contained in:
parent
b585fed8fa
commit
b60e13504f
1 changed files with 6 additions and 8 deletions
|
@ -347,19 +347,17 @@ export async function findTagFromReleases(
|
|||
owner: string,
|
||||
repo: string,
|
||||
tag: string,
|
||||
) {
|
||||
let _release: Release | undefined;
|
||||
for await (const response of releaser.allReleases({
|
||||
): Promise<Release | undefined> {
|
||||
for await (const { data: releases } of releaser.allReleases({
|
||||
owner,
|
||||
repo,
|
||||
})) {
|
||||
_release = response.data.find((release) => release.tag_name === tag);
|
||||
// detect if we found a release - note that a draft release tag may be an empty string
|
||||
if (typeof _release !== "undefined") {
|
||||
break;
|
||||
const release = releases.find((release) => release.tag_name === tag);
|
||||
if (release) {
|
||||
return release;
|
||||
}
|
||||
}
|
||||
return _release;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async function createRelease(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue