Skip to content

Commit

Permalink
Compare versions loosely in UI (loic-sharma#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
loic-sharma authored Jan 4, 2020
1 parent 847142f commit 89c75ee
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/BaGet.UI/src/DisplayPackage/DisplayPackage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Icon } from 'office-ui-fabric-react/lib/Icon';
import * as React from 'react';
import ReactMarkdown from 'react-markdown';
import timeago from 'timeago.js';
import { gt } from 'semver';
import { coerce, gt, SemVer } from 'semver';

import { config } from '../config';
import Dependencies from './Dependencies';
Expand Down Expand Up @@ -317,16 +317,21 @@ class DisplayPackage extends React.Component<IDisplayPackageProps, IDisplayPacka
}

private latestVersion(index: Registration.IRegistrationIndex): string | null {
let latestVersion: string | null = null;
let latestVersionString: string | null = null;
let latestVersion: SemVer | null = null;
for (const entry of index.items[0].items) {
if (!entry.catalogEntry.listed) continue;

if (latestVersion === null || gt(entry.catalogEntry.version, latestVersion)) {
latestVersion = entry.catalogEntry.version;
let entryVersion = coerce(entry.catalogEntry.version);
if (!!entryVersion) {
if (latestVersion === null || gt(entryVersion, latestVersion)) {
latestVersionString = entry.catalogEntry.version;
latestVersion = entryVersion;
}
}
}

return latestVersion;
return latestVersionString;
}
}

Expand Down

0 comments on commit 89c75ee

Please sign in to comment.