From fb554e54e42bb13f21d7ed8bc32ae3207ca1e696 Mon Sep 17 00:00:00 2001 From: Damian Stasik Date: Sun, 23 Jan 2022 12:18:48 +0100 Subject: [PATCH] fix: handle uncaught exceptions thrown by package-json --- Parse-Dashboard/app.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Parse-Dashboard/app.js b/Parse-Dashboard/app.js index 32a4579386..7af0fb2db5 100644 --- a/Parse-Dashboard/app.js +++ b/Parse-Dashboard/app.js @@ -9,13 +9,18 @@ var fs = require('fs'); const currentVersionFeatures = require('../package.json').parseDashboardFeatures; var newFeaturesInLatestVersion = []; -packageJson('parse-dashboard', { version: 'latest', fullMetadata: true }).then(latestPackage => { - if (latestPackage.parseDashboardFeatures instanceof Array) { - newFeaturesInLatestVersion = latestPackage.parseDashboardFeatures.filter(feature => { - return currentVersionFeatures.indexOf(feature) === -1; - }); - } -}); +packageJson('parse-dashboard', { version: 'latest', fullMetadata: true }) + .then(latestPackage => { + if (latestPackage.parseDashboardFeatures instanceof Array) { + newFeaturesInLatestVersion = latestPackage.parseDashboardFeatures.filter(feature => { + return currentVersionFeatures.indexOf(feature) === -1; + }); + } + }) + .catch(() => { + // In case of a failure make sure the final value is an empty array + newFeaturesInLatestVersion = []; + }); function getMount(mountPath) { mountPath = mountPath || '';