Skip to content

Commit

Permalink
build: Don't throw when 'releases' is undefined
Browse files Browse the repository at this point in the history
In case `versions.json` could not be properly downloaded/parsed by
'node-version-data', avoid `TypeError: Cannot read property 'find' of undefined`
when `releases` is `undefined` and return `undefined` instead.

Error should be handled properly elsewhere.

See: #1618
  • Loading branch information
fhemberger committed Apr 8, 2018
1 parent 97363ba commit 4b220fe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scripts/helpers/latestversion.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ const map = (release) => release && {
}

exports.current = (releases) => {
const match = releases.find((release) => !release.lts && semver.gte(release.version, '5.0.0'))
const match = releases && releases.find((release) => !release.lts && semver.gte(release.version, '5.0.0'))
return map(match)
}

exports.lts = (releases) => map(releases.find((release) => release.lts))
exports.lts = (releases) => map(releases && releases.find((release) => release.lts))

function majorStr (release) {
return `v${semver.major(release.version)}.x`
Expand Down

0 comments on commit 4b220fe

Please sign in to comment.