Fixes #219 Add argument to allow only updating drafts and prereleases

This commit is contained in:
Nick Cipollo
2022-10-02 16:31:41 -04:00
committed by Nick Cipollo
parent fc324198c9
commit 5b3ed26ce2
14 changed files with 192 additions and 7 deletions

20
src/ReleaseValidator.ts Normal file
View File

@@ -0,0 +1,20 @@
export class ReleaseValidator {
constructor(private updateOnlyUnreleased: boolean) {
}
validateReleaseUpdate(releaseResponse: ReleaseStageArguments) {
if (!this.updateOnlyUnreleased) {
return
}
if (!releaseResponse.draft && !releaseResponse.prerelease) {
throw new Error(`Tried to update "${releaseResponse.name ?? "release"}" which is neither a draft or prerelease. (updateOnlyUnreleased is on)`)
}
}
}
export type ReleaseStageArguments = {
draft: boolean
name: string | null
prerelease: boolean
}