From 4b220feaa71105112a28947a0c8814ad4cae99fd Mon Sep 17 00:00:00 2001 From: Frederic Hemberger Date: Sun, 8 Apr 2018 07:05:58 +0200 Subject: [PATCH] build: Don't throw when 'releases' is undefined 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 --- scripts/helpers/latestversion.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/helpers/latestversion.js b/scripts/helpers/latestversion.js index 2b16773112274..f41a668c4bd79 100644 --- a/scripts/helpers/latestversion.js +++ b/scripts/helpers/latestversion.js @@ -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`