From d625e527d6d8d4abe37abc36d3b490beb1e3bef7 Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Thu, 5 Dec 2019 20:24:39 +0200 Subject: [PATCH] Fix crash in update checker if package.json's repository value is set to a repository without releases --- src/data/updates.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/data/updates.js b/src/data/updates.js index d5a574e..a57bc62 100644 --- a/src/data/updates.js +++ b/src/data/updates.js @@ -60,7 +60,9 @@ async function refreshVersions() { res.on('data', chunk => data += chunk); res.on('end', async () => { const parsed = JSON.parse(data); - let latestVersion = parsed[0].name; + if (! Array.isArray(parsed) || parsed.length === 0) return; + + const latestVersion = parsed[0].name; await knex('updates').update({ available_version: latestVersion, last_checked: moment.utc().format('YYYY-MM-DD HH:mm:ss')