Skip to content

Commit 97f6cdf

Browse files
authored
refactor: Optimize latest package version check (#2748)
1 parent c0bc92f commit 97f6cdf

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

Parse-Dashboard/app.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,34 @@
11
'use strict';
2+
23
const express = require('express');
34
const path = require('path');
4-
const packageJson = require('package-json');
55
const csrf = require('csurf');
66
const Authentication = require('./Authentication.js');
77
const fs = require('fs');
88
const ConfigKeyCache = require('./configKeyCache.js');
9-
109
const currentVersionFeatures = require('../package.json').parseDashboardFeatures;
1110

1211
let newFeaturesInLatestVersion = [];
13-
packageJson('parse-dashboard', { version: 'latest', fullMetadata: true })
14-
.then(latestPackage => {
12+
13+
/**
14+
* Gets the new features in the latest version of Parse Dashboard.
15+
*/
16+
async function getNewFeaturesInLatestVersion() {
17+
// Get latest version
18+
const packageJson = (await import('package-json')).default;
19+
const latestPackage = await packageJson('parse-dashboard', { version: 'latest', fullMetadata: true });
20+
21+
try {
1522
if (latestPackage.parseDashboardFeatures instanceof Array) {
1623
newFeaturesInLatestVersion = latestPackage.parseDashboardFeatures.filter(feature => {
1724
return currentVersionFeatures.indexOf(feature) === -1;
1825
});
1926
}
20-
})
21-
.catch(() => {
22-
// In case of a failure make sure the final value is an empty array
27+
} catch {
2328
newFeaturesInLatestVersion = [];
24-
});
29+
}
30+
}
31+
getNewFeaturesInLatestVersion()
2532

2633
function getMount(mountPath) {
2734
mountPath = mountPath || '';

0 commit comments

Comments
 (0)