Skip to content

Commit

Permalink
fix: updated semantics to error on null version
Browse files Browse the repository at this point in the history
  • Loading branch information
jbristowe committed May 3, 2022
1 parent 767b69f commit ed9f79d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/octopusCLIVersionFetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@ import {maxSatisfying, valid} from 'semver'
export class OctopusCLIVersionFetcher {
constructor(readonly versions: string[]) {}

getVersion(versionSpec: string): string | null {
getVersion(versionSpec: string): string {
if (versionSpec === '*') {
return maxSatisfying(this.versions, versionSpec)
const version = maxSatisfying(this.versions, versionSpec)
if (!version) {
throw new Error(
`A version satisfying '${versionSpec}' could not be found.`
)
}

return version
}

if (valid(versionSpec) === null) {
Expand Down

0 comments on commit ed9f79d

Please sign in to comment.