Skip to content

Commit

Permalink
use semver to compare versions (#72107)
Browse files Browse the repository at this point in the history
  • Loading branch information
neptunian committed Jul 16, 2020
1 parent acf0617 commit a994f57
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import { SavedObjectsClientContract } from 'src/core/server';
import Boom from 'boom';
import semver from 'semver';
import { PACKAGES_SAVED_OBJECT_TYPE } from '../../../constants';
import {
AssetReference,
Expand Down Expand Up @@ -95,8 +96,7 @@ export async function installPackage(options: {
// TODO: calls to getInstallationObject, Registry.fetchInfo, and Registry.fetchFindLatestPackge
// and be replaced by getPackageInfo after adjusting for it to not group/use archive assets
const latestPackage = await Registry.fetchFindLatestPackage(pkgName);

if (pkgVersion < latestPackage.version)
if (semver.lt(pkgVersion, latestPackage.version))
throw Boom.badRequest('Cannot install or update to an out-of-date package');

const paths = await Registry.getArchiveInfo(pkgName, pkgVersion);
Expand Down

0 comments on commit a994f57

Please sign in to comment.